0

I open the chrome console and add function to catch all error in application:

window.onerror = function (a,b,c,d,e) {
  console.log('my handler: ', a,b,c,d,e);
}

I throw an exception in the same window but I got unreadable error data

setTimeout(() => { throw 'bla bla'; })

my handler: Script error. 0 0 null

enter image description here

Why I cannot read error message?

customcommander
  • 17,580
  • 5
  • 58
  • 84
Yuriy Gyerts
  • 1,464
  • 18
  • 30
  • 1
    Possibly just related to the console. Doing it in the console, it doesn't look like it is caught (in Firefox). Though if I make a jsfiddle of it, it does get caught. – Taplar Dec 10 '20 at 22:00
  • Also if you want to throw an actual Error, you need to `throw new Error('bla bla');` – Taplar Dec 10 '20 at 22:01
  • 1
    Does this answer your question? [Chrome: Will an error in code invoked from the dev console trigger window.onerror?](https://stackoverflow.com/questions/17534054/chrome-will-an-error-in-code-invoked-from-the-dev-console-trigger-window-onerro) – Aplet123 Dec 10 '20 at 22:04

0 Answers0