Skip to content

Are try-catch wrapper and Global error handler alternative options? #4

@MNF

Description

@MNF

According to your https://enrose.github.io/React/redux-saga-error-handling.html post there are 2 alternative options.
As I understand, they have different purpose:
“ try-catch wrapper” handlers errors within saga functions(generators),
“ Global error handler” (Option 1) in middleware handles errors happened in reducer, not sagas.

According to https://redux.js.org/advanced/middleware Redux middleware provides a third-party extension point between dispatching an action, and the moment it reaches the reducer.
So it couldn’t catch the errors in sagas.
Please correct me, if my understanding wrong.

sagaMiddleware.run(rootSaga).done.catch ( option 2) doesn’t allow to compensate/handle error.

From https://redux-saga.js.org/docs/basics/ErrorHandling.html:

Errors in forked tasks bubble up to their parents until it is caught or reaches the root saga. If an error propagates to the root saga the whole saga tree is already terminated.

So you can only log the error and terminate application, as sagas are corrupted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions