From 371aba1639f53fdaa922e7ddb147aebc05601e53 Mon Sep 17 00:00:00 2001 From: Toby Farris Date: Tue, 13 Dec 2022 13:08:19 -0800 Subject: [PATCH] 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 --- src/templates/core/functions/catchErrorCodes.hbs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/templates/core/functions/catchErrorCodes.hbs b/src/templates/core/functions/catchErrorCodes.hbs index 8e87583a..4110f086 100644 --- a/src/templates/core/functions/catchErrorCodes.hbs +++ b/src/templates/core/functions/catchErrorCodes.hbs @@ -16,6 +16,16 @@ const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => } if (!result.ok) { - throw new ApiError(options, result, 'Generic Error'); + const resultBody = (() => { + try { + return JSON.stringify(result.body, null, 2); + } catch (err) { + return undefined; + } + })(); + throw new ApiError( + result, + `Generic Error: status: ${result.status ?? 'unknown'}; status text: ${result.statusText}; body: ${resultBody}` + ); } };