Skip to content

Commit d03854c

Browse files
committed
add response body string to unknown error message
If incoming error response is unknow error, we only make best effort to infer the error type. This change puts error response body to error message so that users have the information they need. This change is necessary for Node because when error response is unknown, the body stream will never be consumed, which would use a lot of resources before stream is flushed.
1 parent 6297831 commit d03854c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpProtocolGeneratorUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ static Set<StructureShape> generateErrorDispatcher(
203203
// Build a generic error the best we can for ones we don't know about.
204204
writer.write("default:").indent()
205205
.write("errorCode = errorCode || \"UnknownError\";")
206-
.openBlock("response = {", "};", () -> {
206+
.openBlock("response = {", "} as any;", () -> {
207207
writer.write("__type: `$L#$${errorCode}`,", operation.getId().getNamespace());
208208
writer.write("$$fault: \"client\",");
209209
writer.write("$$metadata: deserializeMetadata(output),");
210+
writer.write("message: await collectBodyString(output.body, context)");
210211
}).dedent();
211212
});
212213
writer.write("return Promise.reject(Object.assign(new Error(response.__type), response));");

0 commit comments

Comments
 (0)