N
N
newaitix2018-03-06 13:03:54
JavaScript
newaitix, 2018-03-06 13:03:54

Why is the error handler not working?

Is there a way to globally catch the error so that it doesn't get thrown to the console?
Suppose.
Several files with scripts are included on the page.
Each file has different errors.
If you prescribe before any scripts

window.onerror = function(message, source, lineno) {
alert("Ошибка:"+message +"\n" +
"файл:" + source + "\n" +
"строка:" + lineno);
};

will not help. It doesn't even print these errors to the console. Why ?
If you have a library, it has 5000 lines. That on each line to insert try catch is not a way out. Wrapping the entire site in a try catch is also dibilism. For some reason, it is possible to intercept a click, but an error cannot be. Breb crazy simple.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2018-03-06
@xmoonlight

Check by code: is there a redefinition of the onerror global event somewhere inside the code and is all the necessary code in a try-catch?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question