File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 15
15
16
16
package software .amazon .smithy .aws .typescript .codegen ;
17
17
18
+ import java .util .Map ;
19
+ import java .util .Optional ;
18
20
import java .util .Set ;
21
+ import java .util .TreeMap ;
22
+ import software .amazon .smithy .aws .traits .protocols .AwsQueryErrorTrait ;
19
23
import software .amazon .smithy .aws .traits .protocols .AwsQueryTrait ;
20
24
import software .amazon .smithy .codegen .core .SymbolReference ;
21
25
import software .amazon .smithy .model .shapes .OperationShape ;
@@ -171,4 +175,23 @@ protected void deserializeOutputDocument(
171
175
public void generateProtocolTests (GenerationContext context ) {
172
176
AwsProtocolUtils .generateProtocolTests (this , context );
173
177
}
178
+
179
+ @ Override
180
+ public Map <String , ShapeId > getOperationErrors (GenerationContext context , OperationShape operation ) {
181
+ Map <String , ShapeId > errors = new TreeMap <>();
182
+
183
+ operation .getErrors ().forEach (shapeId -> {
184
+ Shape errorShape = context .getModel ().expectShape (shapeId );
185
+ String errorName = shapeId .getName (context .getService ());
186
+
187
+ Optional <AwsQueryErrorTrait > errorShapeTrait = errorShape .getTrait (AwsQueryErrorTrait .class );
188
+ if (errorShapeTrait .isPresent ()) {
189
+ errors .put (errorShapeTrait .get ().getCode (), shapeId );
190
+ } else {
191
+ errors .put (errorName , shapeId );
192
+ }
193
+ });
194
+
195
+ return errors ;
196
+ }
174
197
}
You can’t perform that action at this time.
0 commit comments