This rule effects failures if catchError
is used in an effect or epic in a manner that will complete the outermost observable.
Examples of incorrect code for this rule:
actions.pipe(
ofType("SOMETHING"),
switchMap((action) => something(action)),
catchError(handleError)
);
Examples of correct code for this rule:
actions.pipe(
ofType("SOMETHING"),
switchMap((action) => something(action).pipe(
catchError(handleError)
))
);
actions.pipe(
ofType("SOMETHING"),
switchMap((action) => something(action)),
catchError((error, caught) => {
handleError(error);
return caught;
})
);
This rule accepts a single option which is an object with an observable
property that is a regular expression used to match an effect or epic's actions observable. The default observable
regular expression should match most effect and epic action sources.
{
"rxjs/no-unsafe-catch": [
"error",
{ "observable": "[Aa]ction(s|s\\$|\\$)$" }
]
}