The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

18 lines
429 B

  1. import { showAlertForError } from '../actions/alerts';
  2. const defaultFailSuffix = 'FAIL';
  3. export default function errorsMiddleware() {
  4. return ({ dispatch }) => next => action => {
  5. if (action.type && !action.skipAlert) {
  6. const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
  7. if (action.type.match(isFail)) {
  8. dispatch(showAlertForError(action.error));
  9. }
  10. }
  11. return next(action);
  12. };
  13. };