填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

ErrorHandler

Provides a hook for centralized exception handling.

查看"说明"...

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

说明

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.

方法

handleError(error: any): void
      
      handleError(error: any): void
    
参数
error any
返回值

void

使用说明

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 {}