Skip to content

Commit 698f054

Browse files
authored
Merge pull request #4597 from eddy-aws/main
Add awsQueryCompatible error code translation support
2 parents 5ce492c + 3f9c4f2 commit 698f054

File tree

11 files changed

+812
-3
lines changed

11 files changed

+812
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "6b25cc1a-38cf-4e22-9728-e8e169b9152b",
3+
"type": "feature",
4+
"description": "Add awsQueryCompatible error code translation support",
5+
"modules": [
6+
"."
7+
]
8+
}

private/model/api/api.go

+14
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ type Metadata struct {
9696
ServiceID string
9797

9898
NoResolveEndpoint bool
99+
AWSQueryCompatible *awsQueryCompatible
99100
}
100101

102+
type awsQueryCompatible struct {}
103+
101104
// ProtocolSettings define how the SDK should handle requests in the context
102105
// of of a protocol.
103106
type ProtocolSettings struct {
@@ -639,7 +642,11 @@ func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint,
639642
{{- if and $.WithGeneratedTypedErrors (gt (len $.ShapeListErrors) 0) }}
640643
{{- $_ := $.AddSDKImport "private/protocol" }}
641644
svc.Handlers.UnmarshalError.PushBackNamed(
645+
{{- if .Metadata.AWSQueryCompatible }}
646+
protocol.NewUnmarshalErrorHandler({{ .ProtocolPackage }}.NewUnmarshalTypedErrorWithOptions(exceptionFromCode, {{ .ProtocolPackage }}.WithQueryCompatibility(queryExceptionFromCode))).NamedHandler(),
647+
{{- else }}
642648
protocol.NewUnmarshalErrorHandler({{ .ProtocolPackage }}.NewUnmarshalTypedError(exceptionFromCode)).NamedHandler(),
649+
{{- end}}
643650
)
644651
{{- else }}
645652
svc.Handlers.UnmarshalError.PushBackNamed({{ .ProtocolPackage }}.UnmarshalErrorHandler)
@@ -933,6 +940,13 @@ const (
933940
"{{ $s.ErrorName }}": newError{{ $s.ShapeName }},
934941
{{- end }}
935942
}
943+
{{- if .Metadata.AWSQueryCompatible }}
944+
var queryExceptionFromCode = map[string]func(protocol.ResponseMetadata, string)error {
945+
{{- range $_, $s := $.ShapeListErrors }}
946+
"{{ $s.ErrorName }}": newQueryCompatibleError{{ $s.ShapeName }},
947+
{{- end }}
948+
}
949+
{{- end }}
936950
{{- end }}
937951
`))
938952

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
{
3+
"version":"2.0",
4+
"metadata":{
5+
"apiVersion":"2012-11-05",
6+
"awsQueryCompatible": {
7+
8+
},
9+
"endpointPrefix":"awsqc-exampleendpoint",
10+
"jsonVersion":"1.1",
11+
"protocol":"json",
12+
"serviceAbbreviation":"AwsQueryCompatible",
13+
"serviceFullName":"AWSQuery Compatible Service",
14+
"serviceId":"AWSQueryCompatible",
15+
"signatureVersion":"v4",
16+
"uid":"awsquerycompatible-2012-11-05",
17+
"xmlNamespace":"http://queue.amazonaws.com/doc/2012-11-05/"
18+
},
19+
"operations":{
20+
"CreateQueue":{
21+
"name":"CreateQueue",
22+
"http":{
23+
"method":"POST",
24+
"requestUri":"/"
25+
},
26+
"input":{"shape":"CreateQueueRequest"},
27+
"output":{
28+
"shape":"CreateQueueResult",
29+
"resultWrapper":"CreateQueueResult"
30+
},
31+
"errors":[
32+
{"shape":"QueueDeletedRecently"},
33+
{"shape":"QueueNameExists"}
34+
]
35+
}
36+
},
37+
"shapes":{
38+
"CreateQueueRequest":{
39+
"type":"structure",
40+
"required":["QueueName"],
41+
"members":{
42+
"QueueName":{"shape":"String"}
43+
}
44+
},
45+
"CreateQueueResult":{
46+
"type":"structure",
47+
"members":{
48+
"QueueUrl":{"shape":"String"}
49+
}
50+
},
51+
"QueueDeletedRecently":{
52+
"type":"structure",
53+
"members":{
54+
},
55+
"error":{
56+
"code":"AWS.SimpleQueueService.QueueDeletedRecently",
57+
"httpStatusCode":400,
58+
"senderFault":true
59+
},
60+
"exception":true
61+
},
62+
"QueueNameExists":{
63+
"type":"structure",
64+
"members":{
65+
},
66+
"error":{
67+
"code":"QueueAlreadyExists",
68+
"httpStatusCode":400,
69+
"senderFault":true
70+
},
71+
"exception":true
72+
},
73+
"String":{"type":"string"}
74+
}
75+
}

0 commit comments

Comments
 (0)