Skip to content

Commit

Permalink
feat: add url to error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
stingalleman committed Sep 1, 2022
1 parent 5a84099 commit 0ea660f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/lib/http/HttpManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,17 @@ export class HttpClient {
// throw error if bad request
if (res.status === 400) {
throw new BadRequestError(
`bad request\n${JSON.stringify(err.response.data, null, ' ')}`,
`bad request (${err.config.url})\n${JSON.stringify(err.response.data, null, ' ')}`,
err.stack
);
}

// throw error if forbideden
if (res.status === 403) {
throw new ForbiddenError(
`forbidden, are you sure you have the right scopes?\n${JSON.stringify(
res.data,
null,
' '
)}`,
`forbidden, are you sure you have the right scopes? (${
err.config.url
})\n${JSON.stringify(res.data, null, ' ')}`,
err.stack
);
}
Expand All @@ -258,7 +256,7 @@ export class HttpClient {
}

if (res.status === 401) {
throw new AuthError('unauthorized', err.stack);
throw new AuthError(`unauthorized (${err.config.url})`, err.stack);
// await this.handleAuth();
// const res = await client.request(err.config);
// return res;
Expand Down Expand Up @@ -327,7 +325,7 @@ export class HttpClient {
await this.sleep(retry * 1000); // wait for retry time
res = await client.request(err.config); // retry request
} else {
throw new RatelimitError('hit ratelimit', err.stack);
throw new RatelimitError(`hit ratelimit (${err.config.url})`, err.stack);
}
return res;
}
Expand Down

0 comments on commit 0ea660f

Please sign in to comment.