From d28999f868d9bc9277b566aff041fd0afc03738d Mon Sep 17 00:00:00 2001 From: Stijn van der Kolk Date: Tue, 9 Jul 2024 09:16:23 +0200 Subject: [PATCH] fix: throw errors without response directly --- src/lib/http/HttpManager.ts | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/lib/http/HttpManager.ts b/src/lib/http/HttpManager.ts index 75043e0..22eff56 100644 --- a/src/lib/http/HttpManager.ts +++ b/src/lib/http/HttpManager.ts @@ -337,7 +337,7 @@ export class HttpClient { } statusCode = nRes.status; } catch (error) { - if (!axios.isAxiosError(error)) { + if (!axios.isAxiosError(error) || !error.response) { throw error; } @@ -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 + ); } } }