Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular multiple error handlers

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?

like image 946
TheHawk Avatar asked Mar 16 '26 08:03

TheHawk


1 Answers

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);
   }
}
like image 56
TheHawk Avatar answered Mar 19 '26 00:03

TheHawk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!