Let's say if I have a class
class Foo {
doSomething() { throw 'error'; }
doOtherthing() { throw 'error2'; }
handleError(e) {}
}
Is there any implementation to automatically intercept/catch any error that happens in this class and redirect it to an error handling method, in this case handleError()
e.g
const foo = new Foo()
foo.doSomething()
That should trigger errorHandler(). Angular has such implementation and I am not sure how it got done.