Skip to content

Commit a2dd58d

Browse files
authored
Translate AwsQueryError only if awsQueryCompatible trait is present (#4247)
* Translate AwsQueryError only if awsQueryCompatible trait is present * Fix linting
1 parent 37f7ad4 commit a2dd58d

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
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": "Make AwsQueryCompatible translation only if trait is found"
5+
}

lib/event_listeners.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,13 @@ AWS.EventListeners = {
319319
});
320320

321321
add('ERROR', 'error', function ERROR(err, resp) {
322-
var headers = resp.httpResponse.headers;
323-
var queryErrorCode = headers ? headers['x-amzn-query-error'] : undefined;
324-
if (queryErrorCode) {
325-
resp.error.code = queryErrorCode.split(';')[0];
322+
var awsQueryCompatible = resp.request.service.api.awsQueryCompatible;
323+
if (awsQueryCompatible) {
324+
var headers = resp.httpResponse.headers;
325+
var queryErrorCode = headers ? headers['x-amzn-query-error'] : undefined;
326+
if (queryErrorCode && queryErrorCode.includes(';')) {
327+
resp.error.code = queryErrorCode.split(';')[0];
328+
}
326329
}
327330
}, true);
328331

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, 'awsQueryCompatible', api.awsQueryCompatible);
8384
}
8485

8586
/**

test/helpers.js

Lines changed: 7 additions & 2 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: 18 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)