@Override public void handleError(ClientHttpResponse response) throws IOException { Map<String, Object> errorDetails = extractErrorDetailsFromResponse(response); String message = (String) errorDetails.get("message"); HttpStatus statusCode = response.getStatusCode(); if (statusCode.equals(HttpStatus.UNAUTHORIZED)) { throw new NotAuthorizedException("linkedIn", message); } else if (statusCode.equals(HttpStatus.FORBIDDEN)) { if (message.contains("Throttle")) { throw new RateLimitExceededException("linkedin"); } else { throw new InsufficientPermissionException("linkedin"); } } else if (statusCode.equals(HttpStatus.NOT_FOUND)) { throw new ResourceNotFoundException("linkedin", message); } handleUncategorizedError(response); }
@Override public void handleError(ClientHttpResponse response) throws IOException { Map<String, Object> errorDetails = extractErrorDetailsFromResponse(response); String message = (String) errorDetails.get("message"); HttpStatus statusCode = response.getStatusCode(); if (statusCode.equals(HttpStatus.UNAUTHORIZED)) { throw new NotAuthorizedException("linkedIn", message); } else if (statusCode.equals(HttpStatus.FORBIDDEN)) { if (message.contains("Throttle")) { throw new RateLimitExceededException("linkedin"); } else { throw new InsufficientPermissionException("linkedin"); } } else if (statusCode.equals(HttpStatus.NOT_FOUND)) { throw new ResourceNotFoundException("linkedin", message); } handleUncategorizedError(response); }
private void handleSalesforceError(HttpStatus statusCode, Map<String, Object> errorDetails) { if (statusCode.equals(HttpStatus.NOT_FOUND)) { throw new ResourceNotFoundException(SalesforceServiceProvider.ID, extractErrorMessage(errorDetails)); } else if (statusCode.equals(HttpStatus.SERVICE_UNAVAILABLE)) { throw new RateLimitExceededException(SalesforceServiceProvider.ID); } else if (statusCode.equals(HttpStatus.INTERNAL_SERVER_ERROR)) { throw new InternalServerErrorException(SalesforceServiceProvider.ID, errorDetails == null ? "Contact Salesforce administrator." : extractErrorMessage(errorDetails)); } else if (statusCode.equals(HttpStatus.BAD_REQUEST) || statusCode.equals(HttpStatus.MULTIPLE_CHOICES)) { throw new SalesforceRequestException(SalesforceServiceProvider.ID, errorDetails); } else if (statusCode.equals(HttpStatus.UNAUTHORIZED)) { throw new InvalidAuthorizationException(SalesforceServiceProvider.ID, extractErrorMessage(errorDetails)); } else if (statusCode.equals(HttpStatus.FORBIDDEN)) { if(errorDetails.get(ERROR_CODE).equals(BAD_OAUTH_TOKEN)) { //This is recoverable by refreshing oauth tokens. throw new InsufficientPermissionException(extractErrorMessage(errorDetails)); } else { throw new InsufficientPermissionException(extractErrorMessage(errorDetails)); } } }
throw new RateLimitExceededException(FACEBOOK_PROVIDER_ID); } else if (code == PERMISSION_DENIED || isUserPermissionError(code)) { throw new InsufficientPermissionException(FACEBOOK_PROVIDER_ID); } else if (code == PARAM_SESSION_KEY || code == PARAM_SIGNATURE) { throw new InvalidAuthorizationException(FACEBOOK_PROVIDER_ID, error.getMessage());
throw new RateLimitExceededException(FACEBOOK_PROVIDER_ID); } else if (code == PERMISSION_DENIED || isUserPermissionError(code)) { throw new InsufficientPermissionException(FACEBOOK_PROVIDER_ID); } else if (code == PARAM_SESSION_KEY || code == PARAM_SIGNATURE) { throw new InvalidAuthorizationException(FACEBOOK_PROVIDER_ID, error.getMessage());