Guest User

Untitled

a guest
Jul 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. // This middleware handles both synchronous and asynchronous errors
  2. // that happen during action dispatch.
  3.  
  4. const errorMiddleware = errorHandler => {
  5. return store => {
  6. return next => {
  7. return async action => {
  8. try {
  9. return await next(action);
  10. } catch (err) {
  11. errorHandler(err, store.getState, action, store.dispatch);
  12. return err;
  13. }
  14. };
  15. };
  16. };
  17. };
  18.  
  19. export default errorMiddleware;
Add Comment
Please, Sign In to add comment