I am making use of the ErrorHandler in Angular. It works fine if i am working with only one module. When i am using multiple modules and want to use different error handlers in a specific child module, it does not work. Only the parent error handler is invoked.
RootModule
|--> provides CustomErrorHandler1
|
|--> ChildModule1
| |--> provides CustomErrorHandler2
|
|--> ChildModule2
|--> provides CustomErrorHandler1
If an error occures in ChildModule1 or ChildModule2 the error is always handled by the CustomErrorHandler1 instance of RootModule.
I am using lazy-loading to load those modules. Providing different instances of the same service works for all @Injectable()s except for the error handler.
Is it possible to provide those ErrorHandlers so that the errors in each module will be handled by the ErrorHandler provided in their module definition?
I created a sample repository at github. It can be run via ng serve. If you click on "child1" an error is thrown by Childmodule1 and if you click on "child2" an error is thrown by Childmodule2.
rootmodule, it will override all other error handlers in it's children, try removing your handler onapp.module.tsand just extend fromErrorHandlerfrom inside of your children