Suppress Chrome 'Failed to load resource'

2019-01-01 07:21发布

问题:

I\'m writing a script that uses an XMLHttpRequest to search for a file defined by a relative path, by attempting to resolve that relative path against other same domain absolute paths that the script is aware of, then attempting to load the file from that resolved url. If I encounter a 404, I just try to resolve the files relative path against another absolute path, and try again. For this particular script, its perfectly fine to encounter a 404- however, my console is littered with \'Failed to load resource: the server responded with a status of 404 (Not Found) messages, and I want to suppress them.

There is no error to catch as far as I can see- error cases are handled by the xmlHttpRequest.onreadystatechange handler, and there is no window.onerror.

Is there any way to suppress these messages?

Thanks

回答1:

This feature was introduced last year. You can enable it here: DevTools->Settings->General->Console->Hide network messages.

\"Hiding

See also Filtering the Console output and Additional settings in the devtools documentation.



回答2:

Unfortunately, this can\'t be done, as this type of message in the console is printed by chrome itself. Repressing this type of message has been debated for years, but the consensus seems to be that this message is desirable.