Created
August 23, 2017 13:48
-
-
Save mrister/0cbd47e80e1d53438e1575bb9d64b620 to your computer and use it in GitHub Desktop.
Global UI error handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {BrowserModule} from '@angular/platform-browser'; | |
import {ErrorHandler, NgModule, Injectable} from '@angular/core'; | |
import {AppComponent} from './app.component'; | |
@Injectable() | |
class UIErrorHandler extends ErrorHandler { | |
constructor() { | |
super(); | |
} | |
handleError(error) { | |
super.handleError(error); | |
alert(`Error occurred:${error.message}`); | |
} | |
} | |
@NgModule({ | |
declarations: [AppComponent], | |
imports: [BrowserModule], | |
// add the UI error handler | |
providers: [ | |
provide: ErrorHandler, | |
useClass: UIErrorHandler | |
}], | |
bootstrap: [AppComponent] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 20
{
missingshould be
providers: [{