P
P
Pantene7422020-06-10 19:21:03
Angular
Pantene742, 2020-06-10 19:21:03

How to catch Rx.js stream error in one pipe?

I use a homemade analogue of Ngrx in my project, I send a link to its prototype below (stackblitz).
https://stackblitz.com/edit/rxjs-qy2jk8
I don't want to handle an error in every action, actions are Subjects that are inside the merge. Then I also
add reduced to this pipe via the scan operator.
I would like to handle errors in actions in one place using one catchError.
In line 21, if you uncomment the code, then the Alex action will be executed, And for the rest of the pipe, the stack will fall

actions$.next({ userName: "Alex" }); // If someActionWithError$ throws Error 
                                     // Other dispatches dont work
actions$.next({ userName: "SomeOtherName" });
actions$.next({ userName: "SomeOtherName2" });
actions$.next({ userName: "SomeOtherName3" });


If you uncomment the code in 22 where the pipe error is being handled, then everything will be fine, but I don’t want to handle it in every action. But I want to catch the error in one place for all actions.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question