redux-utilities / redux-promise

FSA-compliant promise middleware for Redux.
MIT License
2.67k stars 134 forks source link

Don't swallow errors #25

Closed benjamingr closed 7 years ago

benjamingr commented 8 years ago

The fact this middleware swallows errors makes debugging hard. I think for the very least in addition to marking error: true it would be useful to call a hook notifying the user of the error - at least when debugging.

munjalpatel commented 8 years ago

+1 -- I also need this functionality.

aprct commented 8 years ago

+1

We can't develop without errors, unfortunately. Will be looking into something else until this is addressed.

wwalser commented 8 years ago

What you want has been addressed here.

Until a new version is published to NPM, the following work when you're using flux standard actions:

const asyncAction = performAsyncAction();
dispatch(asyncAction);
asyncAction.catch(err => console.log("here is my error:", err));
dispatch(performAsyncAction())
    .then(asyncActionResult => {
        if (asyncActionResult.error) {
            console.log("here is my error:", asyncActionResult.payload);
        }
    });
pocesar commented 7 years ago

that's actually how promises work. if you decide to use something like bluebird, it'll emit verbose warnings with stacktraces about unhandled rejections. you're in charge of handling your errors (as you would in try / catch statements, if / elses, etc) plus it already propagate the rejection after dispatching the error https://github.com/acdlite/redux-promise/blob/master/src/index.js#L20

benjamingr commented 7 years ago

@pocesar native promises and most libraries (NPO and RSVP lagging behind, but it's not a huge deal anymore) now emit warnings. This issue was about getting some indication about the error.

Note that this issue is old, and has since been addressed in both popular middlewares that do promises, I just forgot to close it.