I want to improve this code to avoid repetitive method calls.Is there a way to fix this??I don't want to call the same methods updateIndicator and createErrorResponse method every time in if else blocks.
if (e.getRawStatusCode() == NOT_FOUND) {
String errorDetails = createNotFoundDetails(transactionId);
updateIdentifier(identifier);
return createErrorResponse(MISSING_VALID_TRANSACTION_ID_ERROR_MSG, errorDetails);
}
else if (e.getRawStatusCode() == UNAUTHORIZED) {
updateIdentifier(identifier);
if (responseHeaderValue.equals(TOKEN_EXPIRED) ) {
return createErrorResponse(UNABLE_TO_REACH_SVC_PROVIDER_ERROR_MSG,
INVALID_RESPONSE_FROM_SVC_PROVIDER_EXPIRED_TOKEN_ERROR_DETAILS);
}
return createErrorResponse(UNABLE_TO_REACH_SVC_PROVIDER_ERROR_MSG,
INVALID_RESPONSE_FROM_SVC_PROVIDER_INVALID_TOKEN_ERROR_DETAILS);
}
else {
updateIdentifier(identifier);
return createErrorResponse(UNABLE_TO_REACH_SVC_PROVIDER,
UNABLE_TO_REACH_SVC_PROVIDER_ERROR_DETAILS);
}
Aucun commentaire:
Enregistrer un commentaire