W3cubDocs

/Angular 4 TypeScript

ErrorHandler

Stable Class

What it does

Provides a hook for centralized exception handling.

Class Overview

class ErrorHandler {
  constructor(/**
       * @deprecated since v4.0 parameter no longer has an effect, as ErrorHandler will never
       * rethrow.
       */
      deprecatedParameter?: boolean)
  
  
  handleError(error: any) : void
}

Class 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.

Example

class MyErrorHandler implements ErrorHandler {
  handleError(error) {
    // do something with the exception
  }
}

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

Constructor

constructor(/**
       * @deprecated since v4.0 parameter no longer has an effect, as ErrorHandler will never
       * rethrow.
       */
      deprecatedParameter?: boolean)

Class Details

handleError(error: any) : void

exported from core/index, defined in core/src/error_handler.ts

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/docs/ts/latest/api/core/index/ErrorHandler-class.html