0

It looks like the old way of doing that was this:

bootstrap(App, [
    provide(ExceptionHandler, { useClass: CustomExceptionHander })
])

How do you do it in the app.module.ts (post rc-5)?

Daniel Patrick
  • 3,980
  • 6
  • 29
  • 49

1 Answers1

2

update ExceptionHandler was renamed to ErrorHandler https://stackoverflow.com/a/35239028/217408

orgiginal

The syntax you use was deprecated a while ago and was removed in recent versions already.
Use object literal syntax like this instead:

@NgModule({
  providers: [{provide: ExceptionHandler, useClass: CustomExceptionHander }],
  ...
})
Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • thank you, that works as long as I'm not trying to inject another service into it. Once I add a service to the constructor though, I'm getting: `Can't resolve all parameters for MadaketExceptionHandler: (?).` – Daniel Patrick Sep 19 '16 at 15:08
  • You need to add the providers for the parameters as well to the `providers: []` of the module. I would need to see more details to give more concrete feedback. – Günter Zöchbauer Sep 19 '16 at 15:11
  • yes, I've done that. Thanks for your help there. This is a different issue. http://stackoverflow.com/questions/39576701/angular-2-injector-cant-find-service-when-loading-customexceptionhandler – Daniel Patrick Sep 19 '16 at 15:21