@aws-sdk/core 3.943.0 → 3.946.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.js +40 -17
- package/dist-cjs/submodules/protocols/index.js +40 -17
- package/dist-es/submodules/protocols/ProtocolLib.js +20 -3
- package/dist-es/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.js +11 -3
- package/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +4 -3
- package/dist-es/submodules/protocols/query/AwsQueryProtocol.js +3 -8
- package/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +3 -1
- package/dist-types/submodules/protocols/ProtocolLib.d.ts +6 -0
- package/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +4 -0
- package/package.json +3 -3
package/dist-cjs/index.js
CHANGED
|
@@ -406,9 +406,18 @@ class ProtocolLib {
|
|
|
406
406
|
const msg = exception.Message ?? additions.Message;
|
|
407
407
|
const error = smithyClient.decorateServiceException(exception, additions);
|
|
408
408
|
if (msg) {
|
|
409
|
-
error.Message = msg;
|
|
410
409
|
error.message = msg;
|
|
411
410
|
}
|
|
411
|
+
error.Error = {
|
|
412
|
+
...error.Error,
|
|
413
|
+
Type: error.Error.Type,
|
|
414
|
+
Code: error.Error.Code,
|
|
415
|
+
Message: error.Error.message ?? error.Error.Message ?? msg,
|
|
416
|
+
};
|
|
417
|
+
const reqId = error.$metadata.requestId;
|
|
418
|
+
if (reqId) {
|
|
419
|
+
error.RequestId = reqId;
|
|
420
|
+
}
|
|
412
421
|
return error;
|
|
413
422
|
}
|
|
414
423
|
return smithyClient.decorateServiceException(exception, additions);
|
|
@@ -424,7 +433,7 @@ class ProtocolLib {
|
|
|
424
433
|
};
|
|
425
434
|
Object.assign(output, Error);
|
|
426
435
|
for (const [k, v] of entries) {
|
|
427
|
-
Error[k] = v;
|
|
436
|
+
Error[k === "message" ? "Message" : k] = v;
|
|
428
437
|
}
|
|
429
438
|
delete Error.__type;
|
|
430
439
|
output.Error = Error;
|
|
@@ -441,6 +450,14 @@ class ProtocolLib {
|
|
|
441
450
|
errorData.Code = queryCompatErrorData.Code;
|
|
442
451
|
}
|
|
443
452
|
}
|
|
453
|
+
findQueryCompatibleError(registry, errorName) {
|
|
454
|
+
try {
|
|
455
|
+
return registry.getSchema(errorName);
|
|
456
|
+
}
|
|
457
|
+
catch (e) {
|
|
458
|
+
return registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
444
461
|
}
|
|
445
462
|
|
|
446
463
|
class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
|
|
@@ -462,15 +479,23 @@ class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
|
|
|
462
479
|
if (this.awsQueryCompatible) {
|
|
463
480
|
this.mixin.setQueryCompatError(dataObject, response);
|
|
464
481
|
}
|
|
465
|
-
const errorName =
|
|
466
|
-
|
|
482
|
+
const errorName = (() => {
|
|
483
|
+
const compatHeader = response.headers["x-amzn-query-error"];
|
|
484
|
+
if (compatHeader && this.awsQueryCompatible) {
|
|
485
|
+
return compatHeader.split(";")[0];
|
|
486
|
+
}
|
|
487
|
+
return cbor.loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
|
|
488
|
+
})();
|
|
489
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
|
|
467
490
|
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
468
491
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
469
492
|
const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
|
|
470
493
|
const exception = new ErrorCtor(message);
|
|
471
494
|
const output = {};
|
|
472
495
|
for (const [name, member] of ns.structIterator()) {
|
|
473
|
-
|
|
496
|
+
if (dataObject[name] != null) {
|
|
497
|
+
output[name] = this.deserializer.readValue(member, dataObject[name]);
|
|
498
|
+
}
|
|
474
499
|
}
|
|
475
500
|
if (this.awsQueryCompatible) {
|
|
476
501
|
this.mixin.queryCompatOutput(dataObject, output);
|
|
@@ -1035,15 +1060,16 @@ class AwsJsonRpcProtocol extends protocols.RpcProtocol {
|
|
|
1035
1060
|
this.mixin.setQueryCompatError(dataObject, response);
|
|
1036
1061
|
}
|
|
1037
1062
|
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
|
1038
|
-
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
1063
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
|
|
1039
1064
|
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
1040
1065
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
1041
1066
|
const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
|
|
1042
1067
|
const exception = new ErrorCtor(message);
|
|
1043
1068
|
const output = {};
|
|
1044
1069
|
for (const [name, member] of ns.structIterator()) {
|
|
1045
|
-
|
|
1046
|
-
|
|
1070
|
+
if (dataObject[name] != null) {
|
|
1071
|
+
output[name] = this.codec.createDeserializer().readObject(member, dataObject[name]);
|
|
1072
|
+
}
|
|
1047
1073
|
}
|
|
1048
1074
|
if (this.awsQueryCompatible) {
|
|
1049
1075
|
this.mixin.queryCompatOutput(dataObject, output);
|
|
@@ -1563,18 +1589,13 @@ class AwsQueryProtocol extends protocols.RpcProtocol {
|
|
|
1563
1589
|
Code: errorData.Code,
|
|
1564
1590
|
Message: message,
|
|
1565
1591
|
};
|
|
1566
|
-
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata,
|
|
1567
|
-
try {
|
|
1568
|
-
return registry.getSchema(errorName);
|
|
1569
|
-
}
|
|
1570
|
-
catch (e) {
|
|
1571
|
-
return registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName);
|
|
1572
|
-
}
|
|
1573
|
-
});
|
|
1592
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
|
|
1574
1593
|
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
1575
1594
|
const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
|
|
1576
1595
|
const exception = new ErrorCtor(message);
|
|
1577
1596
|
const output = {
|
|
1597
|
+
Type: errorData.Error.Type,
|
|
1598
|
+
Code: errorData.Error.Code,
|
|
1578
1599
|
Error: errorData.Error,
|
|
1579
1600
|
};
|
|
1580
1601
|
for (const [name, member] of ns.structIterator()) {
|
|
@@ -1997,7 +2018,9 @@ class AwsRestXmlProtocol extends protocols.HttpBindingProtocol {
|
|
|
1997
2018
|
}
|
|
1998
2019
|
if (request.headers["content-type"] === this.getDefaultContentType()) {
|
|
1999
2020
|
if (typeof request.body === "string") {
|
|
2000
|
-
request.body
|
|
2021
|
+
if (!request.body.startsWith("<?xml ")) {
|
|
2022
|
+
request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
|
|
2023
|
+
}
|
|
2001
2024
|
}
|
|
2002
2025
|
}
|
|
2003
2026
|
return request;
|
|
@@ -76,9 +76,18 @@ class ProtocolLib {
|
|
|
76
76
|
const msg = exception.Message ?? additions.Message;
|
|
77
77
|
const error = smithyClient.decorateServiceException(exception, additions);
|
|
78
78
|
if (msg) {
|
|
79
|
-
error.Message = msg;
|
|
80
79
|
error.message = msg;
|
|
81
80
|
}
|
|
81
|
+
error.Error = {
|
|
82
|
+
...error.Error,
|
|
83
|
+
Type: error.Error.Type,
|
|
84
|
+
Code: error.Error.Code,
|
|
85
|
+
Message: error.Error.message ?? error.Error.Message ?? msg,
|
|
86
|
+
};
|
|
87
|
+
const reqId = error.$metadata.requestId;
|
|
88
|
+
if (reqId) {
|
|
89
|
+
error.RequestId = reqId;
|
|
90
|
+
}
|
|
82
91
|
return error;
|
|
83
92
|
}
|
|
84
93
|
return smithyClient.decorateServiceException(exception, additions);
|
|
@@ -94,7 +103,7 @@ class ProtocolLib {
|
|
|
94
103
|
};
|
|
95
104
|
Object.assign(output, Error);
|
|
96
105
|
for (const [k, v] of entries) {
|
|
97
|
-
Error[k] = v;
|
|
106
|
+
Error[k === "message" ? "Message" : k] = v;
|
|
98
107
|
}
|
|
99
108
|
delete Error.__type;
|
|
100
109
|
output.Error = Error;
|
|
@@ -111,6 +120,14 @@ class ProtocolLib {
|
|
|
111
120
|
errorData.Code = queryCompatErrorData.Code;
|
|
112
121
|
}
|
|
113
122
|
}
|
|
123
|
+
findQueryCompatibleError(registry, errorName) {
|
|
124
|
+
try {
|
|
125
|
+
return registry.getSchema(errorName);
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
return registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
114
131
|
}
|
|
115
132
|
|
|
116
133
|
class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
|
|
@@ -132,15 +149,23 @@ class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
|
|
|
132
149
|
if (this.awsQueryCompatible) {
|
|
133
150
|
this.mixin.setQueryCompatError(dataObject, response);
|
|
134
151
|
}
|
|
135
|
-
const errorName =
|
|
136
|
-
|
|
152
|
+
const errorName = (() => {
|
|
153
|
+
const compatHeader = response.headers["x-amzn-query-error"];
|
|
154
|
+
if (compatHeader && this.awsQueryCompatible) {
|
|
155
|
+
return compatHeader.split(";")[0];
|
|
156
|
+
}
|
|
157
|
+
return cbor.loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
|
|
158
|
+
})();
|
|
159
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
|
|
137
160
|
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
138
161
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
139
162
|
const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
|
|
140
163
|
const exception = new ErrorCtor(message);
|
|
141
164
|
const output = {};
|
|
142
165
|
for (const [name, member] of ns.structIterator()) {
|
|
143
|
-
|
|
166
|
+
if (dataObject[name] != null) {
|
|
167
|
+
output[name] = this.deserializer.readValue(member, dataObject[name]);
|
|
168
|
+
}
|
|
144
169
|
}
|
|
145
170
|
if (this.awsQueryCompatible) {
|
|
146
171
|
this.mixin.queryCompatOutput(dataObject, output);
|
|
@@ -705,15 +730,16 @@ class AwsJsonRpcProtocol extends protocols.RpcProtocol {
|
|
|
705
730
|
this.mixin.setQueryCompatError(dataObject, response);
|
|
706
731
|
}
|
|
707
732
|
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
|
708
|
-
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
733
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
|
|
709
734
|
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
710
735
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
711
736
|
const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
|
|
712
737
|
const exception = new ErrorCtor(message);
|
|
713
738
|
const output = {};
|
|
714
739
|
for (const [name, member] of ns.structIterator()) {
|
|
715
|
-
|
|
716
|
-
|
|
740
|
+
if (dataObject[name] != null) {
|
|
741
|
+
output[name] = this.codec.createDeserializer().readObject(member, dataObject[name]);
|
|
742
|
+
}
|
|
717
743
|
}
|
|
718
744
|
if (this.awsQueryCompatible) {
|
|
719
745
|
this.mixin.queryCompatOutput(dataObject, output);
|
|
@@ -1233,18 +1259,13 @@ class AwsQueryProtocol extends protocols.RpcProtocol {
|
|
|
1233
1259
|
Code: errorData.Code,
|
|
1234
1260
|
Message: message,
|
|
1235
1261
|
};
|
|
1236
|
-
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata,
|
|
1237
|
-
try {
|
|
1238
|
-
return registry.getSchema(errorName);
|
|
1239
|
-
}
|
|
1240
|
-
catch (e) {
|
|
1241
|
-
return registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName);
|
|
1242
|
-
}
|
|
1243
|
-
});
|
|
1262
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
|
|
1244
1263
|
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
1245
1264
|
const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
|
|
1246
1265
|
const exception = new ErrorCtor(message);
|
|
1247
1266
|
const output = {
|
|
1267
|
+
Type: errorData.Error.Type,
|
|
1268
|
+
Code: errorData.Error.Code,
|
|
1248
1269
|
Error: errorData.Error,
|
|
1249
1270
|
};
|
|
1250
1271
|
for (const [name, member] of ns.structIterator()) {
|
|
@@ -1667,7 +1688,9 @@ class AwsRestXmlProtocol extends protocols.HttpBindingProtocol {
|
|
|
1667
1688
|
}
|
|
1668
1689
|
if (request.headers["content-type"] === this.getDefaultContentType()) {
|
|
1669
1690
|
if (typeof request.body === "string") {
|
|
1670
|
-
request.body
|
|
1691
|
+
if (!request.body.startsWith("<?xml ")) {
|
|
1692
|
+
request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
|
|
1693
|
+
}
|
|
1671
1694
|
}
|
|
1672
1695
|
}
|
|
1673
1696
|
return request;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TypeRegistry } from "@smithy/core/schema";
|
|
1
|
+
import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
|
|
2
2
|
import { decorateServiceException } from "@smithy/smithy-client";
|
|
3
3
|
export class ProtocolLib {
|
|
4
4
|
queryCompat;
|
|
@@ -67,9 +67,18 @@ export class ProtocolLib {
|
|
|
67
67
|
const msg = exception.Message ?? additions.Message;
|
|
68
68
|
const error = decorateServiceException(exception, additions);
|
|
69
69
|
if (msg) {
|
|
70
|
-
error.Message = msg;
|
|
71
70
|
error.message = msg;
|
|
72
71
|
}
|
|
72
|
+
error.Error = {
|
|
73
|
+
...error.Error,
|
|
74
|
+
Type: error.Error.Type,
|
|
75
|
+
Code: error.Error.Code,
|
|
76
|
+
Message: error.Error.message ?? error.Error.Message ?? msg,
|
|
77
|
+
};
|
|
78
|
+
const reqId = error.$metadata.requestId;
|
|
79
|
+
if (reqId) {
|
|
80
|
+
error.RequestId = reqId;
|
|
81
|
+
}
|
|
73
82
|
return error;
|
|
74
83
|
}
|
|
75
84
|
return decorateServiceException(exception, additions);
|
|
@@ -85,7 +94,7 @@ export class ProtocolLib {
|
|
|
85
94
|
};
|
|
86
95
|
Object.assign(output, Error);
|
|
87
96
|
for (const [k, v] of entries) {
|
|
88
|
-
Error[k] = v;
|
|
97
|
+
Error[k === "message" ? "Message" : k] = v;
|
|
89
98
|
}
|
|
90
99
|
delete Error.__type;
|
|
91
100
|
output.Error = Error;
|
|
@@ -102,4 +111,12 @@ export class ProtocolLib {
|
|
|
102
111
|
errorData.Code = queryCompatErrorData.Code;
|
|
103
112
|
}
|
|
104
113
|
}
|
|
114
|
+
findQueryCompatibleError(registry, errorName) {
|
|
115
|
+
try {
|
|
116
|
+
return registry.getSchema(errorName);
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
return registry.find((schema) => NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
105
122
|
}
|
|
@@ -20,15 +20,23 @@ export class AwsSmithyRpcV2CborProtocol extends SmithyRpcV2CborProtocol {
|
|
|
20
20
|
if (this.awsQueryCompatible) {
|
|
21
21
|
this.mixin.setQueryCompatError(dataObject, response);
|
|
22
22
|
}
|
|
23
|
-
const errorName =
|
|
24
|
-
|
|
23
|
+
const errorName = (() => {
|
|
24
|
+
const compatHeader = response.headers["x-amzn-query-error"];
|
|
25
|
+
if (compatHeader && this.awsQueryCompatible) {
|
|
26
|
+
return compatHeader.split(";")[0];
|
|
27
|
+
}
|
|
28
|
+
return loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
|
|
29
|
+
})();
|
|
30
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
|
|
25
31
|
const ns = NormalizedSchema.of(errorSchema);
|
|
26
32
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
27
33
|
const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
|
|
28
34
|
const exception = new ErrorCtor(message);
|
|
29
35
|
const output = {};
|
|
30
36
|
for (const [name, member] of ns.structIterator()) {
|
|
31
|
-
|
|
37
|
+
if (dataObject[name] != null) {
|
|
38
|
+
output[name] = this.deserializer.readValue(member, dataObject[name]);
|
|
39
|
+
}
|
|
32
40
|
}
|
|
33
41
|
if (this.awsQueryCompatible) {
|
|
34
42
|
this.mixin.queryCompatOutput(dataObject, output);
|
|
@@ -54,15 +54,16 @@ export class AwsJsonRpcProtocol extends RpcProtocol {
|
|
|
54
54
|
this.mixin.setQueryCompatError(dataObject, response);
|
|
55
55
|
}
|
|
56
56
|
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
|
57
|
-
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
57
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
|
|
58
58
|
const ns = NormalizedSchema.of(errorSchema);
|
|
59
59
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
60
60
|
const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
|
|
61
61
|
const exception = new ErrorCtor(message);
|
|
62
62
|
const output = {};
|
|
63
63
|
for (const [name, member] of ns.structIterator()) {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if (dataObject[name] != null) {
|
|
65
|
+
output[name] = this.codec.createDeserializer().readObject(member, dataObject[name]);
|
|
66
|
+
}
|
|
66
67
|
}
|
|
67
68
|
if (this.awsQueryCompatible) {
|
|
68
69
|
this.mixin.queryCompatOutput(dataObject, output);
|
|
@@ -95,18 +95,13 @@ export class AwsQueryProtocol extends RpcProtocol {
|
|
|
95
95
|
Code: errorData.Code,
|
|
96
96
|
Message: message,
|
|
97
97
|
};
|
|
98
|
-
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata,
|
|
99
|
-
try {
|
|
100
|
-
return registry.getSchema(errorName);
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
return registry.find((schema) => NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
98
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
|
|
106
99
|
const ns = NormalizedSchema.of(errorSchema);
|
|
107
100
|
const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
|
|
108
101
|
const exception = new ErrorCtor(message);
|
|
109
102
|
const output = {
|
|
103
|
+
Type: errorData.Error.Type,
|
|
104
|
+
Code: errorData.Error.Code,
|
|
110
105
|
Error: errorData.Error,
|
|
111
106
|
};
|
|
112
107
|
for (const [name, member] of ns.structIterator()) {
|
|
@@ -40,7 +40,9 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
|
|
|
40
40
|
}
|
|
41
41
|
if (request.headers["content-type"] === this.getDefaultContentType()) {
|
|
42
42
|
if (typeof request.body === "string") {
|
|
43
|
-
request.body
|
|
43
|
+
if (!request.body.startsWith("<?xml ")) {
|
|
44
|
+
request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
|
|
45
|
+
}
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
return request;
|
|
@@ -51,5 +51,11 @@ export declare class ProtocolLib {
|
|
|
51
51
|
* @param errorData - canonical error object returned to the caller.
|
|
52
52
|
*/
|
|
53
53
|
queryCompatOutput(queryCompatErrorData: any, errorData: any): void;
|
|
54
|
+
/**
|
|
55
|
+
* Finds the canonical modeled error using the awsQueryError alias.
|
|
56
|
+
* @param registry - service error registry.
|
|
57
|
+
* @param errorName - awsQueryError name or regular qualified shapeId.
|
|
58
|
+
*/
|
|
59
|
+
findQueryCompatibleError(registry: TypeRegistry, errorName: string): StaticErrorSchema;
|
|
54
60
|
}
|
|
55
61
|
export {};
|
|
@@ -39,5 +39,9 @@ export declare class ProtocolLib {
|
|
|
39
39
|
response: IHttpResponse
|
|
40
40
|
): void;
|
|
41
41
|
queryCompatOutput(queryCompatErrorData: any, errorData: any): void;
|
|
42
|
+
findQueryCompatibleError(
|
|
43
|
+
registry: TypeRegistry,
|
|
44
|
+
errorName: string
|
|
45
|
+
): StaticErrorSchema;
|
|
42
46
|
}
|
|
43
47
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.946.0",
|
|
4
4
|
"description": "Core functions & classes shared by multiple AWS SDK clients.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
@@ -83,12 +83,12 @@
|
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@aws-sdk/types": "3.936.0",
|
|
85
85
|
"@aws-sdk/xml-builder": "3.930.0",
|
|
86
|
-
"@smithy/core": "^3.18.
|
|
86
|
+
"@smithy/core": "^3.18.7",
|
|
87
87
|
"@smithy/node-config-provider": "^4.3.5",
|
|
88
88
|
"@smithy/property-provider": "^4.2.5",
|
|
89
89
|
"@smithy/protocol-http": "^5.3.5",
|
|
90
90
|
"@smithy/signature-v4": "^5.3.5",
|
|
91
|
-
"@smithy/smithy-client": "^4.9.
|
|
91
|
+
"@smithy/smithy-client": "^4.9.10",
|
|
92
92
|
"@smithy/types": "^4.9.0",
|
|
93
93
|
"@smithy/util-base64": "^4.3.0",
|
|
94
94
|
"@smithy/util-middleware": "^4.2.5",
|