Skip to content

Commit 280e96f

Browse files
authored
Merge pull request ferdikoomen#1363 from LittleUmbrella/master
add more detail to Generic Error message for easier troubleshooting
2 parents 9e2c37d + 371aba1 commit 280e96f

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 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult):
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)