Search code examples
angularngrxsentryngrx-effects

Error Interceptor for ngrx 4 effects


I want to send errors to a service like Sentry, but ngrx 4 doesn't use Angular's ErrorHandler. How can I create a global error interceptor for ngrx 4 effects?


Solution

  • https://github.com/ngrx/platform/pull/635 allows to use Angular's ErrorHandler or a custom one by adding { provide: ErrorReporter, useClass: CustomErrorHandler }, to your providers.

    The error message will only contain Error: Effect "EffectsClass.EffectName$" threw an error. The real error will be available in error.Notification.error.

    This is not yet released, and only available in the nightly builds (ngrx/entity-builds). In ngrx 5, providing a custom ErrorHandler will be enough to catch effects errors.