mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Bugfix: actions should always throw errors
This commit is contained in:
		
							parent
							
								
									41984f976b
								
							
						
					
					
						commit
						f79e5f191b
					
				| @ -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: | ||||
|  | ||||
| @ -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; | ||||
|     }; | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user