From ad71fc680561071b99a3879c319ff72eaba54af2 Mon Sep 17 00:00:00 2001 From: Drylozu <35281350+Drylozu@users.noreply.github.com> Date: Mon, 4 Nov 2024 18:23:09 -0500 Subject: [PATCH] feat: show API method on request error --- src/api/api.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/api.ts b/src/api/api.ts index b91c1c02..56a037eb 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -167,7 +167,7 @@ export class ApiHandler { } } } - const parsedError = this.parseError(route, response, result); + const parsedError = this.parseError(method, route, response, result); this.debugger?.warn(parsedError); reject(parsedError); return; @@ -207,7 +207,7 @@ export class ApiHandler { }); } - parseError(route: `/${string}`, response: Response, result: unknown) { + parseError(method: HttpMethods, route: `/${string}`, response: Response, result: unknown) { let errMessage = ''; if (typeof result === 'object' && result) { if ('message' in result) { @@ -218,7 +218,7 @@ export class ApiHandler { errMessage += `${JSON.stringify(result.errors, null, 2)}\n`; } } - errMessage += ` at [${response.status} ${response.statusText}] ${route}`; + errMessage += ` at [${response.status} ${response.statusText}] ${method} ${route}\n`; return new Error(errMessage); }