V
V
Vladimir Golub2019-12-09 10:31:58
JavaScript
Vladimir Golub, 2019-12-09 10:31:58

How to catch all errors in an application if some functions are already wrapped in try ... catch?

What is the correct way to catch application errors in one place if some functions are already wrapped in try catch ?
Interested in both back and front.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Ineshin, 2019-12-09
@RazerVG

There is a `catch` for this, call your function in it. Something like this:
https://jsfiddle.net/g9xwf42h/

function parseError(er) {
    console.log(er);
}


try {
    var a = "test";
    alert(a.b.c);
} catch (er) {
    parseError(er);
}



try {
    var b = "test2";
    alert(b.c.d);
} catch (er) {
    parseError(er);
}

X
xmoonlight, 2019-12-09
@xmoonlight

Add a break point to catch (the rest is as usual).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question