Skip to content

Commit 371aba1

Browse files
add more detail to Generic Error message for easier troubleshooting. 'Generic Error' gives no insight into the nature of the issue, whereas having at least the http status conveys a great deal for troubleshooting
1 parent 8a1e04f commit 371aba1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/templates/core/functions/catchErrorCodes.hbs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void =>
1616
}
1717

1818
if (!result.ok) {
19-
throw new ApiError(options, result, 'Generic Error');
19+
const resultBody = (() => {
20+
try {
21+
return JSON.stringify(result.body, null, 2);
22+
} catch (err) {
23+
return undefined;
24+
}
25+
})();
26+
throw new ApiError(
27+
result,
28+
`Generic Error: status: ${result.status ?? 'unknown'}; status text: ${result.statusText}; body: ${resultBody}`
29+
);
2030
}
2131
};

0 commit comments

Comments
 (0)