2016-01-27 19:34:44 +00:00
|
|
|
// () =>
|
|
|
|
// (store: Store) =>
|
|
|
|
// (next: (action: Action) => Object) =>
|
|
|
|
// errSaga(action: Action) => Object|Void
|
|
|
|
export default () => ({ dispatch }) => next => {
|
|
|
|
return function errorSaga(action) {
|
2016-03-03 04:54:14 +00:00
|
|
|
const result = next(action);
|
|
|
|
if (!action.error) { return result; }
|
2016-01-27 19:34:44 +00:00
|
|
|
|
|
|
|
console.error(action.error);
|
2016-03-03 04:54:14 +00:00
|
|
|
return dispatch({
|
2016-01-27 19:34:44 +00:00
|
|
|
type: 'app.makeToast',
|
|
|
|
payload: {
|
|
|
|
type: 'error',
|
|
|
|
title: 'Oops, something went wrong',
|
2016-03-03 04:54:14 +00:00
|
|
|
message: 'Something went wrong, please try again later'
|
2016-01-27 19:34:44 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|