Help Angular by taking a 1 minute survey!Go to surveyHome

ErrorHandler

Provides a hook for centralized exception handling.

See more...

      
      class ErrorHandler {
  handleError(error: any): void
}
    

Description

The default implementation of ErrorHandler prints error messages to the console. To intercept error handling, write a custom exception handler that replaces this default as appropriate for your app.

Methods

handleError(error: any): void
      
      handleError(error: any): void
    
Parameters
error any
Returns

void

Usage notes

Example

class MyErrorHandler implements ErrorHandler { handleError(error) { // do something with the exception } } @NgModule({ providers: [{provide: ErrorHandler, useClass: MyErrorHandler}] }) class MyModule {}
      
      class MyErrorHandler implements ErrorHandler {
  handleError(error) {
    // do something with the exception
  }
}

@NgModule({
  providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
})
class MyModule {}