Skip to content

Commit

Permalink
fix: Better Axios errors
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Dec 9, 2023
1 parent 83cf98d commit 6a2baf3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ export const postData = async <T = unknown>({
let m: string;
if (err.response) {
// Request made and server responded
m = `${err.response.status?.toString()} ${JSON.stringify(
m = `[${err.response.status?.toString()}] ${JSON.stringify(
err.response.data
)}`; // eslint-disable-line
)} ${err.message}`; // eslint-disable-line
} else if (err.request) {
// The request was made but no response was received
m = 'Error in request';
m = 'Error in request, no response received: ' + err.message;
} else {
// Something happened in setting up the request that triggered an Error
m = 'Error: ' + err.message;
}

throw new Error(m);
throw m ? new Error(m) : err;
} else {
throw err;
}
Expand Down

1 comment on commit 6a2baf3

@vercel
Copy link

@vercel vercel bot commented on 6a2baf3 Dec 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.