mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-25 21:55:49 +00:00
return the actual axios error with the custom error message in bruno-cli axios-instance
This commit is contained in:
@@ -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++;
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user