Skip to content

Commit

Permalink
feat: show API method on request error
Browse files Browse the repository at this point in the history
  • Loading branch information
Drylozu committed Nov 4, 2024
1 parent 15dd80a commit ad71fc6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}

Expand Down

0 comments on commit ad71fc6

Please sign in to comment.