ngrx/store

ngrx effects error handling when reducer throws error within FailureAction

dee-cf opened this issue · 1 comments

We have effects defined as:

@Effect()
  loadAll$: Observable<Action> = this.actions$
    .ofType(actions.ActionTypes.LOAD_ALL)
    .map(action => action.payload)
    .switchMap((options) => {
      return this.service.loadAll(options)
        .map(all=> new actions.LoadAllCompleteAction(all))
        .catch(() => Observable.of(new actions.LoadAllFailureAction(null)));
    });

there is a reducer listening for LoadAllFailureAction and does changes to some flags in store.

Now, if in handling that action (in reducer) i do object destructuring of that null (sent in LoadAllFailureAction), which producec TypeError, that error is not caught by GlobalErrorHandler (which catches uncaught exceptions). Also, effects stops running.

On the other hand, with exactly the same effects/reducers setup, if i manually do throw Error() in reducer, it does get caught.

Now that's a complete mystery for me.

Any thoughts?

tplk commented

As far as I'm concerned all new issues should be posted in monorepo: https://github.com/ngrx/platform