0

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)

ernesto petit
  • 1,436
  • 1
  • 14
  • 19

2 Answers2

1

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

henok
  • 864
  • 5
  • 12
1

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.

Heisenbug
  • 213
  • 1
  • 6