Skip to content

Commit

Permalink
fix: throw errors without response directly
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvdkolk committed Jul 9, 2024
1 parent 49b3820 commit d28999f
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/lib/http/HttpManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class HttpClient {
}
statusCode = nRes.status;
} catch (error) {
if (!axios.isAxiosError(error)) {
if (!axios.isAxiosError(error) || !error.response) {
throw error;
}

Expand All @@ -364,22 +364,11 @@ export class HttpClient {

default:
if (i === this.config.retry5xxAmount) {
// handling axios error @see https://axios-http.com/docs/handling_errors
if (error.response) {
throw new RequestRetriesExceededError(
`Request exceeded ${this.config.retry5xxAmount} number of retry attempts, failed with status code ${statusCode}`,
error.config.url,
error.stack
);
}

if (error.request) {
throw new RequestRetriesExceededError(
`Request exceeded ${this.config.retry5xxAmount} number of retry attempts, no response received`,
error.config.url,
error.stack
);
}
throw new RequestRetriesExceededError(
`Request exceeded ${this.config.retry5xxAmount} number of retry attempts, failed with status code ${statusCode}`,
error.config.url,
error.stack
);
}
}
}
Expand Down

0 comments on commit d28999f

Please sign in to comment.