Reputation: 121
In our project we already use a custom error handler using
{provide: ErrorHandler, useExisting: CustomErrorHandler}
This CustomErrorHandler is provided by third party which logs errors to a central server. In addition to this we want to implement our own central error handling to display errors on screen.
Is there a way to have multiple error handlers in angular?
Upvotes: 3
Views: 4269
Reputation: 121
Thank you @yurzui, for anyone loooking for code here are the snippets that I used:
AppModule.ts:
{provider: ErrorHandler, useClass: LocalErrorHandler}
LocalErrorHandler.ts:
@Injectable()
export class LocalErrorHandler extends CustomErrorHandler
{
handleError(error: any)
{
//Local custom handling
super.handleError(error);
}
}
Upvotes: 9