0

Executing the follow code shows as an error "GET https://blah.com/42" in my console (Chrome). Why? Shouldn't the error be caught and dismissed?

try {
  var req = new XMLHttpRequest();
  req.open('GET', 'https://blah.com/42', false);
  req.send();
} catch(e) {}
countunique
  • 4,068
  • 6
  • 26
  • 35

3 Answers3

0

The chrome console is not only showing the usual javascript errors. Your request probably returned an error (ex 404 or no rights). Do you try to load another's page code? Coz if you do ... its security issue and chrome will not let you to.

DarkThanos
  • 122
  • 4
  • The request I'm making may be good or bad. Afterwards I check the response code and act accordingly. Just want a way to hide the error message because it's expected and not an error. – countunique Jun 05 '14 at 01:51
0

Screenshot

First, click the the Filter icon (red arrow in the image).

Then, press Ctrl key and, instead of "All", choose "Warnings", "Info", "Logs" and "Debug".

Note this will also hide the errors of JavaScript that runs on the page, but will show them if you run it in the console.

Oriol
  • 274,082
  • 63
  • 437
  • 513
0

For Chrome 60 I found that if you have the debug console open and click the 'cog' icon on the right of the window you get options (including "Log XMLHttpRequests"). The option you need is "Hide network". Enable that and it will no longer show network errors (although they will still be logged, so disabling the option will show them again).

Parakleta
  • 1,121
  • 10
  • 19