Reputation: 1617
I want to handle de 404 error in console. The red ones.
I know that if I do something like
if (http.readyState === 4) {
if (http.status === 400) {
//some code
}
}
I will handle the error, but in the consele, it will appear in red. That is the errot taht I want to avoid.
Utils.js:701 GET http://url/url/id.pdf 404 (Not Found)
Upvotes: 0
Views: 51
Reputation: 223
You can handle the error with a http.status === 404
or with a try... catch
sentence.
However, you can't supress the red message on the chrome's console:
Suppress Chrome 'Failed to load resource' messages in console
The best you can do is console.clear();
when handling the error, but that dosn't work always.
Upvotes: 1
Reputation: 894
There is no way to stop the 404 error message from being displayed inside the browser console.
However, if it is your own server that you are requesting, you can have another request checking for the existence of your file before you request the file, that way you can avoid the 404 error
Upvotes: 1