Model transform(ModelTransformer transformer, Model model) {
        if (forService.getErrors().isEmpty()) {
            return model;
        }

        Set<Shape> toReplace = new HashSet<>();
        TopDownIndex topDownIndex = TopDownIndex.of(model);
        for (OperationShape operation : topDownIndex.getContainedOperations(forService)) {
            Set<ShapeId> errors = new LinkedHashSet<>(operation.getErrors());
            errors.addAll(forService.getErrors());
            toReplace.add(operation.toBuilder().errors(errors).build());
        }

        return transformer.replaceShapes(model, toReplace);
    }
Copies errors from a service onto each operation bound to the service.
smithy-model/src/main/java/software/amazon/smithy/model/transform/CopyServiceErrorsToOperationsTransform.java