I would like to provide a Custom ErrorHandler to our angular project when it is build (using angular-cli) in the production environment.
I've tried what's been said here with no success.
To not leave you without a code sample, this is what I've ended up with:
let providers: Provider[] = [
...
];
if(environment.production) {
providers.push({ provide: ErrorHandler, useClass: MyErrorHandler });
}
@NgModule({
declarations: [
...
],
imports: [
...
],
bootstrap: [AppComponent],
providers: providers
})
But building (or serving) the app:
$ ng build --prod
$ ng serve --prod
Does not include this error handler.
How should I proceed to do so ?