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.

internalServerErrorMiddleware.js 689B

1234567891011121314151617181920
  1. import { attachPostRequestListener } from "../../request";
  2. import { makeErrorToastMessage } from "../../util/helpers/toastMessage";
  3. import i18next from "i18next";
  4. export const serverErrorMiddlewareInterceptorName =
  5. "INTERNAL_SERVER_ERROR_MIDDLEWARE_INTERCEPTOR";
  6. export default () => (next) => (action) => {
  7. attachPostRequestListener((error) => {
  8. if (!error.response) {
  9. return makeErrorToastMessage(i18next.t("apiErrors.SomethingWentWrong"));
  10. }
  11. if (error.response.status === 500) {
  12. return makeErrorToastMessage(i18next.t("apiErrors.SomethingWentWrong"));
  13. }
  14. return Promise.reject(error);
  15. }, serverErrorMiddlewareInterceptorName);
  16. next(action);
  17. };