Skip to content

Commit

Permalink
Changes following review
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox committed Jun 22, 2018
1 parent 7a30d90 commit 70d2495
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/frontend/app/store/effects/api.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,20 @@ export class APIEffect {

let fakedAction, errorMessage;
errors.forEach(error => {
// Dispatch a specific error action for the endpoint that's failed
fakedAction = { ...actionClone, endpointGuid: error.guid };
errorMessage = error.errorResponse ? error.errorResponse.description || error.errorCode : error.errorCode;
this.store.dispatch(new APISuccessOrFailedAction(fakedAction.actions[2], fakedAction, errorMessage));
if (error.error) {
// Dispatch a error action for the specific endpoint that's failed
fakedAction = { ...actionClone, endpointGuid: error.guid };
errorMessage = error.errorResponse ? error.errorResponse.description || error.errorCode : error.errorCode;
this.store.dispatch(new APISuccessOrFailedAction(fakedAction.actions[2], fakedAction, errorMessage));
}
});

// If this request only went out to a single endpoint ... and it failed... send the failed action now and avoid future validation.
// If this request only went out to a single endpoint ... and it failed... send the failed action now and avoid response validation.
// This allows requests sent to multiple endpoints to proceed even if one of those endpoints failed.
const error = errors[0];
if (errors.length === 1 && error.error) {
if (errors.length === 1 && errors[0].error) {
this.store.dispatch(new WrapperRequestActionFailed(
errorMessage,
{ ...actionClone, endpointGuid: error.guid },
{ ...actionClone, endpointGuid: errors[0].guid },
requestType
));
return [];
Expand Down

0 comments on commit 70d2495

Please sign in to comment.