Closed feitzi closed 2 years ago
Use tapResult. See readme.
I updated the sample, and it doesn't work like described in the readme. After the error occurs, the effect cannot used anymore.
sampleEffect = this.createEffectFn(($: Observable<number>) =>
$.pipe(
switchMap(this.fakeApiCall),
tapResult(
(x) => console.log("Further processing of:", x),
(error) => console.error(error)
)
)
);
Can you please adapt my minimal sandbox example to show a working error handling? Maybe then I can create a PR with documentation on this topic for other people.
It should be in the inner observable:
sampleEffect = this.createEffectFn(($: Observable<number>) =>
$.pipe(
switchMap(() => {
return from(fetch('https://not-exists')).pipe(
tapResult(
(x) => console.log("Further processing of:", x),
(error) => console.error(error)
)
)
}),
)
);
Ok, then the documentation is wrong, I created a PR (#31).
But the problem is still there. You would have to give a separate tapResult
call for each call. Is there no possibility to do this with a global error handler?
No, because it depends on the stream.
Which @ngneat/effects-* package(s) are the source of the bug?
effects-ng
Is this a regression?
No
Description
If an effect returns an unhandled exception, it can not be started again. For me its seems like a bug, or some kind of missing documentation to handle errors. It's possible to use
catchError
, but there should be a more generic way to solve that problem?From my submitted sample:
Please provide a link to a minimal reproduction of the bug
https://codesandbox.io/s/elfeffectserrorhandling-oo7qvf?file=/src/app/app.component.ts
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in
No response
Anything else?
No response
Do you want to create a pull request?
Yes