Skip to content

Commit 450b007

Browse files
committed
Add handling for code based exceptions
1 parent d648f1a commit 450b007

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

aws/client/aws-client-awsjson/src/it/java/software/amazon/smithy/java/client/aws/jsonprotocols/AwsJson11ProtocolTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ public void requestTest(DataStream expected, DataStream actual) {
3535
}
3636

3737
@HttpClientResponseTests
38-
@ProtocolTestFilter(
39-
skipTests = {
40-
"AwsJson11FooErrorUsingCode",
41-
"AwsJson11FooErrorUsingCodeAndNamespace",
42-
"AwsJson11FooErrorUsingCodeUriAndNamespace",
43-
})
4438
public void responseTest(Runnable test) {
4539
test.run();
4640
}

aws/client/aws-client-awsjson/src/it/java/software/amazon/smithy/java/client/aws/jsonprotocols/AwsJson1ProtocolTests.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ public void requestTest(DataStream expected, DataStream actual) {
5151
skipTests = {
5252
"AwsJson10ClientPopulatesDefaultsValuesWhenMissingInResponse",
5353
"AwsJson10ClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse",
54-
//The below fail because we haven't implemented code based exception handling
55-
"AwsJson10FooErrorUsingCode",
56-
"AwsJson10FooErrorUsingCodeAndNamespace",
57-
"AwsJson10FooErrorUsingCodeUriAndNamespace",
5854
},
5955
skipOperations = "aws.protocoltests.json10#OperationWithRequiredMembersWithDefaults")
6056
public void responseTest(Runnable test) {

aws/client/aws-client-restjson/src/it/java/software/amazon/smithy/java/client/aws/restjson/RestJson1ProtocolTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ public void requestTest(DataStream expected, DataStream actual) {
5656
}
5757

5858
@HttpClientResponseTests
59-
@ProtocolTestFilter(
60-
skipTests = {
61-
"RestJsonFooErrorUsingCode",
62-
"RestJsonFooErrorUsingCodeAndNamespace",
63-
"RestJsonFooErrorUsingCodeUriAndNamespace",
64-
})
6559
public void responseTest(Runnable test) {
6660
test.run();
6761
}

codecs/json-codec/src/main/java/software/amazon/smithy/java/json/JsonDocuments.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,14 @@ public ShapeType type() {
246246
@Override
247247
public ShapeId discriminator() {
248248
String discriminator = null;
249-
var member = values.get("__type");
250-
if (member != null && member.type() == ShapeType.STRING) {
251-
discriminator = member.asString();
249+
var typeMember = values.get("__type");
250+
if (typeMember != null && typeMember.type() == ShapeType.STRING) {
251+
discriminator = typeMember.asString();
252+
} else {
253+
var codeMember = values.get("code");
254+
if (codeMember != null && codeMember.type() == ShapeType.STRING) {
255+
discriminator = codeMember.asString();
256+
}
252257
}
253258
if (settings.errorTypeSanitizer() != null) {
254259
discriminator = settings.errorTypeSanitizer().apply(discriminator);

0 commit comments

Comments
 (0)