Skip to content

Commit 2a87ec1

Browse files
Sqs AwsJson migration (#4105)
* Add awsQueryCompatible trait support to service When awsQueryCompatible trait is found, it's made available as an API property. When this property is found, the error code is returned by looking up the mapping. This is a pre-requisite for migrating services from AWSQuery wire protocol to AWSJson. * Add additional tests; review comments * Add awsQueryCompatible trait support to service When awsQueryCompatible trait is found, it's made available as an API property. When this property is found, the error code is returned by looking up the mapping. This is a pre-requisite for migrating services from AWSQuery wire protocol to AWSJson. * Add additional tests; review comments * Review comments * Use MockServiceFromApi; Move errorCodeMapping logic to even)listeners * Update on.error function * Fix type * Remove reimplementation of mapping function * Use add instead of addAsync Co-authored-by: AllanZhengYP <[email protected]> * Add null check to error listener * Use simple service null check * Fix add 'Error' implementation * Add changelog Co-authored-by: AllanZhengYP <[email protected]>
1 parent d4a4f4a commit 2a87ec1

File tree

5 files changed

+90
-13
lines changed

5 files changed

+90
-13
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "feature",
3+
"category": "AwsQueryCompatible",
4+
"description": "Add awsQueryCompatible trait support to service"
5+
}

lib/event_listeners.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,16 @@ AWS.EventListeners = {
299299
}
300300
});
301301

302+
add('ERROR', 'error', function ERROR(err, resp) {
303+
var errorCodeMapping = resp.request.service.api.errorCodeMapping;
304+
if (errorCodeMapping && err && err.code) {
305+
var mapping = errorCodeMapping[err.code];
306+
if (mapping) {
307+
resp.error.code = mapping.code;
308+
}
309+
}
310+
}, true);
311+
302312
addAsync('SEND', 'send', function SEND(resp, done) {
303313
resp.httpResponse._abortCallback = done;
304314
resp.error = null;

lib/model/api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function Api(api, options) {
8080
property(this, 'documentation', api.documentation);
8181
property(this, 'documentationUrl', api.documentationUrl);
8282
}
83+
property(this, 'errorCodeMapping', api.awsQueryCompatible);
8384
}
8485

8586
/**

test/helpers.js

Lines changed: 7 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/service.spec.js

Lines changed: 67 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)