ErrorHandler
클래스
안정화
Provides a hook for centralized exception handling.
handleError
void@paramerror
any@returns
voidonViewError
voidCallback to handle errors happening during the rendering of a component/directive view.
@paramerror
ErrorThe error that was thrown.
@returns
void설명
Provides a hook for centralized exception handling.
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
}
}
// Provide in standalone apps
bootstrapApplication(AppComponent, {
providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
})
// Provide in module-based apps
@NgModule({
providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
})
class MyModule {}
상세 내용으로 이동