Is it possible to globally catch exceptions thrown in an Angular 2 application to prevent the entire app from breaking from errors in any one component?
Asked
Active
Viewed 2.1k times
45
-
2See for example http://stackoverflow.com/questions/37592078/cyclic-dependency-when-ovveriding-exceptionhandler/37609925#37609925, http://stackoverflow.com/questions/37609725/how-to-inject-my-service-to-exceptionhandler/37609799#37609799, http://stackoverflow.com/questions/37793276/angular-2-custom-exceptionhandler-change-detection-lag/37793791#37793791, http://stackoverflow.com/questions/35238428/angular2-application-crashes-becomes-unresponsive-after-encountering-an-except/35239028#35239028, – Günter Zöchbauer Jun 30 '16 at 18:45
-
http://stackoverflow.com/questions/37879654/angular-2-rc-2-how-to-inject-router-into-custom-exceptionhandler/37879714#37879714 – Günter Zöchbauer Jun 30 '16 at 18:45
1 Answers
40
As google explain, you can override error handler service to do what you want. https://angular.io/docs/ts/latest/api/core/index/ErrorHandler-class.html

Saulfa
- 416
- 6
- 3