From 217170c2e264d11bca955b85357e80911fd5248c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Tue, 4 May 2021 20:41:19 +0200 Subject: [PATCH] fix: handle generic errors better --- frontend/src/store/api-helper.js | 2 +- frontend/src/store/error/index.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/store/api-helper.js b/frontend/src/store/api-helper.js index 2b65492c55..19b0af36a2 100644 --- a/frontend/src/store/api-helper.js +++ b/frontend/src/store/api-helper.js @@ -62,7 +62,7 @@ export function throwIfNotSuccess(response) { let error = new Error(errorMsg); error.statusCode = response.status; reject(error); - }); + }).catch(() => reject(new Error(defaultErrorMessage))) }); } else { return Promise.reject(new ServiceError(response.status)); diff --git a/frontend/src/store/error/index.js b/frontend/src/store/error/index.js index aaecb20201..e5699876bc 100644 --- a/frontend/src/store/error/index.js +++ b/frontend/src/store/error/index.js @@ -15,6 +15,8 @@ import { ERROR_ADD_CONTEXT_FIELD, ERROR_UPDATE_CONTEXT_FIELD } from '../context/ import { ERROR_REMOVING_PROJECT, ERROR_ADD_PROJECT, ERROR_UPDATE_PROJECT } from '../project/actions'; +import { ERROR_ADD_ADDON_CONFIG, ERROR_UPDATE_ADDON_CONFIG, ERROR_REMOVING_ADDON_CONFIG } from '../addons/actions' + import { UPDATE_APPLICATION_FIELD } from '../application/actions'; import { FORBIDDEN } from '../util'; @@ -48,7 +50,11 @@ const strategies = (state = getInitState(), action) => { case ERROR_UPDATE_CONTEXT_FIELD: case ERROR_REMOVING_PROJECT: case ERROR_UPDATE_PROJECT: + case ERROR_ADD_ADDON_CONFIG: + case ERROR_UPDATE_ADDON_CONFIG: + case ERROR_REMOVING_ADDON_CONFIG: case ERROR_ADD_PROJECT: + console.log(action); return addErrorIfNotAlreadyInList(state, action.error.message); case FORBIDDEN: return addErrorIfNotAlreadyInList(state, action.error.message || '403 Forbidden');