1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

Bugfix: actions should always throw errors

This commit is contained in:
ivaosthu 2018-01-20 13:06:13 +01:00
parent 41984f976b
commit f79e5f191b
2 changed files with 12 additions and 7 deletions

View File

@ -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:

View File

@ -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;
};
}