Skip to content

Commit 6f4f986

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 7058dc6 commit 6f4f986

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
@@ -215,10 +215,11 @@ static Set<StructureShape> generateErrorDispatcher(
215215
// Build a generic error the best we can for ones we don't know about.
216216
writer.write("default:").indent()
217217
.write("errorCode = errorCode || \"UnknownError\";")
218-
.openBlock("response = {", "};", () -> {
218+
.openBlock("response = {", "} as any;", () -> {
219219
writer.write("__type: `$L#$${errorCode}`,", operation.getId().getNamespace());
220220
writer.write("$$fault: \"client\",");
221221
writer.write("$$metadata: deserializeMetadata(output),");
222+
writer.write("message: await collectBodyString(output.body, context)");
222223
}).dedent();
223224
});
224225
writer.write("return Promise.reject(Object.assign(new Error(response.__type), response));");

0 commit comments

Comments
 (0)