import { errorAction, launchAction as launchErrorAction } from "../../../../utils/redux";
/**
 * Launch error if conditions of launchAction are fulfilled.
 */
// eslint-disable-next-line import/prefer-default-export

export var getLaunchErrorMiddleware = function getLaunchErrorMiddleware(store) {
  return function (next) {
    return function (action) {
      try {
        return launchErrorAction(next, action.type, action.payload);
      } catch (err) {
        return next(errorAction(err));
      }
    };
  };
};