Skip to content
This repository has been archived by the owner on Jan 10, 2018. It is now read-only.

ngrx effects error handling when reducer throws error within FailureAction #447

Closed
codefactorydevelopment opened this issue Jul 20, 2017 · 1 comment

Comments

@codefactorydevelopment
Copy link

codefactorydevelopment commented Jul 20, 2017

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?

@codefactorydevelopment codefactorydevelopment changed the title ngrx effects error handling when reducer throws error on FailuerAction ngrx effects error handling when reducer throws error within FailureAction Jul 20, 2017
@tplk
Copy link

tplk commented Jul 21, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants