question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't throw error / catch on 400-level responses

See original GitHub issue

Instead, limit the error/catch to 500-level errors. 400-level responses can be completely valid, expected, desired, etc.

I have been following this pattern with my bunyan logging – logging 400-level responses as warnings, and 500-level responses as errors. The idea is that a successful npm test (which may expect 400-level responses) should show zero logging errors.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:65
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

100reactions
mzabriskiecommented, Apr 27, 2016

This has been added as a feature in 0.11.0 by use of validateStatus config option.

43reactions
jonathanpmartinscommented, Jan 12, 2018

@carlojacobs you can access error.response.data

axios.post('/').then(response => {
    console.log(response.data);
}).catch(error => {
    console.log(error.response.data);
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

FAQ: how do I stop axios from throwing an error on 4XX / 5XX ...
By default, the axios HTTP library throws an error anytime the destination server responds with a 4XX / 5XX error (for example, a...
Read more >
Axios 400 error request call then instead of catch
I found the solution. Problem caused by dont return promise in axios interceptors: axios.interceptors.response.use((response) => { return ...
Read more >
How to catch the body of an AXIOS error - DEV Community ‍ ‍
this doesn't help me, I have api that returns 400 as bad request, with a body, I can't read the body from response...
Read more >
How to Fix a 400 Bad Request Error (Causes and Fixes) - Kinsta
1. URL String Syntax Error. The HTTP error 400 can occur due to incorrectly typed URL, malformed syntax, or a URL that contains...
Read more >
400 Bad Request Error: What It Is and How to Fix It
The 400 Bad Request Error is an HTTP response status code indicating that the server was unable to process the request sent by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found