From d82006937157868de87df6321ec3638fcc4c30ec Mon Sep 17 00:00:00 2001 From: lohit Date: Tue, 27 May 2025 18:41:47 +0530 Subject: [PATCH] return the actual axios error with the custom error message in bruno-cli axios-instance --- packages/bruno-cli/src/utils/axios-instance.js | 10 ++++++---- .../collection/redirects/Disable Redirect.bru | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/bruno-cli/src/utils/axios-instance.js b/packages/bruno-cli/src/utils/axios-instance.js index d3fea8f6d..d0e1ae446 100644 --- a/packages/bruno-cli/src/utils/axios-instance.js +++ b/packages/bruno-cli/src/utils/axios-instance.js @@ -92,14 +92,16 @@ function makeAxiosInstance({ requestMaxRedirects = 5, disableCookies } = {}) { if (redirectResponseCodes.includes(error.response.status)) { if (redirectCount >= requestMaxRedirects) { - const err = new Error(`Maximum redirects (${requestMaxRedirects}) exceeded`); - err.originalError = error; - return Promise.reject(err); + // todo: needs to be discussed whether the original error response message should be modified or not + error.response.data = `Maximum redirects (${requestMaxRedirects}) exceeded`; + return Promise.reject(error); } const locationHeader = error.response.headers.location; if (!locationHeader) { - return Promise.reject(new Error('Redirect location header missing')); + // todo: needs to be discussed whether the original error response message should be modified or not + error.response.data = 'Redirect location header missing'; + return Promise.reject(error); } redirectCount++; diff --git a/packages/bruno-tests/collection/redirects/Disable Redirect.bru b/packages/bruno-tests/collection/redirects/Disable Redirect.bru index 31aedd2f2..b915ca36d 100644 --- a/packages/bruno-tests/collection/redirects/Disable Redirect.bru +++ b/packages/bruno-tests/collection/redirects/Disable Redirect.bru @@ -21,6 +21,6 @@ script:pre-request { tests { test("should disable redirect to ping", function() { const data = res.getBody(); - expect(data).to.equal('Found. Redirecting to /ping'); + expect(data).to.not.equal('pong'); }); }