diff --git a/frontend/src/store/error-store.js b/frontend/src/store/error-store.js index 53a95e778a..bdd2fb9b96 100644 --- a/frontend/src/store/error-store.js +++ b/frontend/src/store/error-store.js @@ -38,7 +38,7 @@ const strategies = (state = getInitState(), action) => { case ERROR_RECEIVE_STRATEGIES: return addErrorIfNotAlreadyInList(state, action.error.message); case FORBIDDEN: - return addErrorIfNotAlreadyInList(state, '403 Forbidden'); + return addErrorIfNotAlreadyInList(state, action.error.message || '403 Forbidden'); case MUTE_ERROR: return state.update('list', list => list.remove(list.indexOf(action.error))); default: diff --git a/frontend/src/store/util.js b/frontend/src/store/util.js index 72b350911c..6d727484b6 100644 --- a/frontend/src/store/util.js +++ b/frontend/src/store/util.js @@ -3,12 +3,17 @@ export const FORBIDDEN = 'FORBIDDEN'; export function dispatchAndThrow(dispatch, type) { return error => { - if (error.statusCode === 401) { - dispatch({ type: AUTH_REQUIRED, error, receivedAt: Date.now() }); - } else if (error.statusCode === 403) { - dispatch({ type: FORBIDDEN, error, receivedAt: Date.now() }); - } else { - dispatch({ type, error, receivedAt: Date.now() }); + switch (error.statusCode) { + case 401: + dispatch({ type: AUTH_REQUIRED, error, receivedAt: Date.now() }); + break; + case 403: + dispatch({ type: FORBIDDEN, error, receivedAt: Date.now() }); + break; + default: + dispatch({ type, error, receivedAt: Date.now() }); + break; } + throw error; }; }