diff --git a/CHANGELOG b/CHANGELOG index 9352e2ec637c6df6d65df6f42f7c3e71ee704b1d..0399b1422fdac9c85391495613c5d56dcfaedbbf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ minerva-front (18.0.0~beta.4) stable; urgency=medium + * Bugfix: connectivity issue should report a problem with network instead of + submitting error report(#293) * Bugfix: source map for js was missing (#292) * Bugfix: sometimes project don't have link to disease or organism, this crashed listing of projects after log in (#290) diff --git a/src/redux/middlewares/error.middleware.ts b/src/redux/middlewares/error.middleware.ts index 56ba18c0f5cfcef3435ac3d6b86aa2e8db452f45..0a8913b5ee876bb9fe9a232525afd75939a6b856 100644 --- a/src/redux/middlewares/error.middleware.ts +++ b/src/redux/middlewares/error.middleware.ts @@ -3,6 +3,9 @@ import { Action, createListenerMiddleware, isRejected } from '@reduxjs/toolkit'; import { createErrorData } from '@/utils/error-report/errorReporting'; import { openAccessDeniedModal, openErrorReportModal } from '@/redux/modal/modal.slice'; import { getProjects } from '@/redux/projects/projects.thunks'; +import axios from 'axios'; +import { AXIOS_ERROR_NETWORK } from '@/utils/getErrorMessage/getErrorMessage.constants'; +import { showToast } from '@/utils/showToast'; export const errorListenerMiddleware = createListenerMiddleware(); @@ -16,6 +19,17 @@ export const errorMiddlewareListener = async ( if (action.error.code === '403') { dispatch(getProjects()); dispatch(openAccessDeniedModal()); + } else if (axios.isAxiosError(action.error) && action.error.code === AXIOS_ERROR_NETWORK) { + // eslint-disable-next-line no-console + console.log(action.error); + showToast({ + type: 'error', + message: + 'There was a problem with fetching data from minerva server. ' + + 'Please check your internet connection and try again. ' + + 'If problem problem persists contact system administrator.', + duration: 15000, + }); } else { const errorData = await createErrorData(action.error, getState()); dispatch(openErrorReportModal(errorData)); diff --git a/src/utils/getErrorMessage/getErrorMessage.constants.ts b/src/utils/getErrorMessage/getErrorMessage.constants.ts index e6d05b2732652bf8ceb927f41c324af05b0526b8..3f9fa192f4ff9070126f2f394fc6f5ea8c19416b 100644 --- a/src/utils/getErrorMessage/getErrorMessage.constants.ts +++ b/src/utils/getErrorMessage/getErrorMessage.constants.ts @@ -2,6 +2,7 @@ export const UNKNOWN_ERROR = 'An unknown error occurred. Please try again later. export const UNKNOWN_AXIOS_ERROR_CODE = 'UNKNOWN_AXIOS_ERROR'; export const NOT_FOUND_AXIOS_ERROR_CODE = '404'; export const GENERIC_AXIOS_ERROR_CODE = 'ERR_BAD_REQUEST'; +export const AXIOS_ERROR_NETWORK = 'ERR_NETWORK'; export const HTTP_ERROR_MESSAGES = { 400: "The server couldn't understand your request. Please check your input and try again.",