Skip to content

Commit 7756845

Browse files
committed
fix(codegen): change only the check, not the return
1 parent 1ffee0e commit 7756845

File tree

131 files changed

+238
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+238
-235
lines changed

clients/client-auto-scaling/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10653,7 +10653,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
1065310653

1065410654
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1065510655
if (data.Error?.Code !== undefined) {
10656-
return data.Error?.Code;
10656+
return data.Error.Code;
1065710657
}
1065810658
if (output.statusCode == 404) {
1065910659
return "NotFound";

clients/client-cloudformation/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10499,7 +10499,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
1049910499

1050010500
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1050110501
if (data.Error?.Code !== undefined) {
10502-
return data.Error?.Code;
10502+
return data.Error.Code;
1050310503
}
1050410504
if (output.statusCode == 404) {
1050510505
return "NotFound";

clients/client-cloudfront/src/protocols/Aws_restXml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18923,7 +18923,7 @@ const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
1892318923

1892418924
const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1892518925
if (data.Error?.Code !== undefined) {
18926-
return data.Error?.Code;
18926+
return data.Error.Code;
1892718927
}
1892818928
if (output.statusCode == 404) {
1892918929
return "NotFound";

clients/client-cloudsearch/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4237,7 +4237,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
42374237

42384238
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
42394239
if (data.Error?.Code !== undefined) {
4240-
return data.Error?.Code;
4240+
return data.Error.Code;
42414241
}
42424242
if (output.statusCode == 404) {
42434243
return "NotFound";

clients/client-cloudwatch/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6419,7 +6419,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
64196419

64206420
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
64216421
if (data.Error?.Code !== undefined) {
6422-
return data.Error?.Code;
6422+
return data.Error.Code;
64236423
}
64246424
if (output.statusCode == 404) {
64256425
return "NotFound";

clients/client-docdb/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9270,7 +9270,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
92709270

92719271
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
92729272
if (data.Error?.Code !== undefined) {
9273-
return data.Error?.Code;
9273+
return data.Error.Code;
92749274
}
92759275
if (output.statusCode == 404) {
92769276
return "NotFound";

clients/client-ec2/src/protocols/Aws_ec2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88327,7 +88327,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
8832788327

8832888328
const loadEc2ErrorCode = (output: __HttpResponse, data: any): string | undefined => {
8832988329
if (data.Errors.Error?.Code !== undefined) {
88330-
return data.Errors.Error?.Code;
88330+
return data.Errors.Error.Code;
8833188331
}
8833288332
if (output.statusCode == 404) {
8833388333
return "NotFound";

clients/client-elastic-beanstalk/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7401,7 +7401,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
74017401

74027402
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
74037403
if (data.Error?.Code !== undefined) {
7404-
return data.Error?.Code;
7404+
return data.Error.Code;
74057405
}
74067406
if (output.statusCode == 404) {
74077407
return "NotFound";

clients/client-elastic-load-balancing-v2/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6881,7 +6881,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
68816881

68826882
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
68836883
if (data.Error?.Code !== undefined) {
6884-
return data.Error?.Code;
6884+
return data.Error.Code;
68856885
}
68866886
if (output.statusCode == 404) {
68876887
return "NotFound";

clients/client-elastic-load-balancing/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4776,7 +4776,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
47764776

47774777
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
47784778
if (data.Error?.Code !== undefined) {
4779-
return data.Error?.Code;
4779+
return data.Error.Code;
47804780
}
47814781
if (output.statusCode == 404) {
47824782
return "NotFound";

clients/client-elasticache/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12879,7 +12879,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
1287912879

1288012880
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1288112881
if (data.Error?.Code !== undefined) {
12882-
return data.Error?.Code;
12882+
return data.Error.Code;
1288312883
}
1288412884
if (output.statusCode == 404) {
1288512885
return "NotFound";

clients/client-iam/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17535,7 +17535,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
1753517535

1753617536
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1753717537
if (data.Error?.Code !== undefined) {
17538-
return data.Error?.Code;
17538+
return data.Error.Code;
1753917539
}
1754017540
if (output.statusCode == 404) {
1754117541
return "NotFound";

clients/client-neptune/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12368,7 +12368,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
1236812368

1236912369
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1237012370
if (data.Error?.Code !== undefined) {
12371-
return data.Error?.Code;
12371+
return data.Error.Code;
1237212372
}
1237312373
if (output.statusCode == 404) {
1237412374
return "NotFound";

clients/client-rds/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25608,7 +25608,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
2560825608

2560925609
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
2561025610
if (data.Error?.Code !== undefined) {
25611-
return data.Error?.Code;
25611+
return data.Error.Code;
2561225612
}
2561325613
if (output.statusCode == 404) {
2561425614
return "NotFound";

clients/client-redshift/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19646,7 +19646,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
1964619646

1964719647
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1964819648
if (data.Error?.Code !== undefined) {
19649-
return data.Error?.Code;
19649+
return data.Error.Code;
1965019650
}
1965119651
if (output.statusCode == 404) {
1965219652
return "NotFound";

clients/client-route-53/src/protocols/Aws_restXml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8986,7 +8986,7 @@ const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
89868986

89878987
const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string | undefined => {
89888988
if (data.Error?.Code !== undefined) {
8989-
return data.Error?.Code;
8989+
return data.Error.Code;
89908990
}
89918991
if (output.statusCode == 404) {
89928992
return "NotFound";

clients/client-s3-control/src/protocols/Aws_restXml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9065,7 +9065,7 @@ const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
90659065

90669066
const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string | undefined => {
90679067
if (data.Error?.Code !== undefined) {
9068-
return data.Error?.Code;
9068+
return data.Error.Code;
90699069
}
90709070
if (output.statusCode == 404) {
90719071
return "NotFound";

clients/client-s3/src/protocols/Aws_restXml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12067,7 +12067,7 @@ const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
1206712067

1206812068
const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string | undefined => {
1206912069
if (data?.Code !== undefined) {
12070-
return data?.Code;
12070+
return data.Code;
1207112071
}
1207212072
if (output.statusCode == 404) {
1207312073
return "NotFound";

clients/client-ses/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9107,7 +9107,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
91079107

91089108
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
91099109
if (data.Error?.Code !== undefined) {
9110-
return data.Error?.Code;
9110+
return data.Error.Code;
91119111
}
91129112
if (output.statusCode == 404) {
91139113
return "NotFound";

clients/client-sns/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5628,7 +5628,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
56285628

56295629
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
56305630
if (data.Error?.Code !== undefined) {
5631-
return data.Error?.Code;
5631+
return data.Error.Code;
56325632
}
56335633
if (output.statusCode == 404) {
56345634
return "NotFound";

clients/client-sqs/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2810,7 +2810,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
28102810

28112811
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
28122812
if (data.Error?.Code !== undefined) {
2813-
return data.Error?.Code;
2813+
return data.Error.Code;
28142814
}
28152815
if (output.statusCode == 404) {
28162816
return "NotFound";

clients/client-sts/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
13451345

13461346
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
13471347
if (data.Error?.Code !== undefined) {
1348-
return data.Error?.Code;
1348+
return data.Error.Code;
13491349
}
13501350
if (output.statusCode == 404) {
13511351
return "NotFound";

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEc2.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ public void generateSharedComponents(GenerationContext context) {
9999
+ " data: any\n"
100100
+ "): string | undefined => {", "};", responseType, () -> {
101101
// Attempt to fetch the error code from the specific location.
102-
String errorCodeLocation = getErrorBodyLocation(context, "data") + "?.Code";
103-
writer.openBlock("if ($L !== undefined) {", "}", errorCodeLocation, () -> {
104-
writer.write("return $L;", errorCodeLocation);
102+
String errorCodeCheckLocation = getErrorBodyLocation(context, "data") + "?.Code";
103+
String errorCodeAccessLocation = getErrorBodyLocation(context, "data") + ".Code";
104+
writer.openBlock("if ($L !== undefined) {", "}", errorCodeCheckLocation, () -> {
105+
writer.write("return $L;", errorCodeAccessLocation);
105106
});
106107

107108
// Default a 404 status code to the NotFound code.

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsQuery.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ public void generateSharedComponents(GenerationContext context) {
103103
+ " data: any\n"
104104
+ "): string | undefined => {", "};", responseType, () -> {
105105
// Attempt to fetch the error code from the specific location.
106-
String errorCodeLocation = getErrorBodyLocation(context, "data") + "?.Code";
107-
writer.openBlock("if ($L !== undefined) {", "}", errorCodeLocation, () -> {
108-
writer.write("return $L;", errorCodeLocation);
106+
String errorCodeCheckLocation = getErrorBodyLocation(context, "data") + "?.Code";
107+
String errorCodeAccessLocation = getErrorBodyLocation(context, "data") + ".Code";
108+
writer.openBlock("if ($L !== undefined) {", "}", errorCodeCheckLocation, () -> {
109+
writer.write("return $L;", errorCodeAccessLocation);
109110
});
110111

111112
// Default a 404 status code to the NotFound code.

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ public void generateSharedComponents(GenerationContext context) {
117117
+ " data: any\n"
118118
+ "): string | undefined => {", "};", responseType, () -> {
119119
// Attempt to fetch the error code from the specific location.
120-
String errorCodeLocation = getErrorBodyLocation(context, "data") + "?.Code";
121-
writer.openBlock("if ($L !== undefined) {", "}", errorCodeLocation, () -> {
122-
writer.write("return $L;", errorCodeLocation);
120+
String errorCodeCheckLocation = getErrorBodyLocation(context, "data") + "?.Code";
121+
String errorCodeAccessLocation = getErrorBodyLocation(context, "data") + ".Code";
122+
writer.openBlock("if ($L !== undefined) {", "}", errorCodeCheckLocation, () -> {
123+
writer.write("return $L;", errorCodeAccessLocation);
123124
});
124125

125126
// Default a 404 status code to the NotFound code.

private/aws-protocoltests-ec2/src/protocols/Aws_ec2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
21412141

21422142
const loadEc2ErrorCode = (output: __HttpResponse, data: any): string | undefined => {
21432143
if (data.Errors.Error?.Code !== undefined) {
2144-
return data.Errors.Error?.Code;
2144+
return data.Errors.Error.Code;
21452145
}
21462146
if (output.statusCode == 404) {
21472147
return "NotFound";

private/aws-protocoltests-query/src/protocols/Aws_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2875,7 +2875,7 @@ const buildFormUrlencodedString = (formEntries: Record<string, string>): string
28752875

28762876
const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => {
28772877
if (data.Error?.Code !== undefined) {
2878-
return data.Error?.Code;
2878+
return data.Error.Code;
28792879
}
28802880
if (output.statusCode == 404) {
28812881
return "NotFound";

private/aws-protocoltests-restxml/src/protocols/Aws_restXml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5555,7 +5555,7 @@ const parseErrorBody = async (errorBody: any, context: __SerdeContext) => {
55555555

55565556
const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string | undefined => {
55575557
if (data.Error?.Code !== undefined) {
5558-
return data.Error?.Code;
5558+
return data.Error.Code;
55595559
}
55605560
if (output.statusCode == 404) {
55615561
return "NotFound";

0 commit comments

Comments
 (0)