in abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java [37:72]
public void handleError(final HttpCommand command, final HttpResponse response) {
Exception exception = null;
String defaultMessage = String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
response.getStatusLine());
try {
switch (response.getStatusCode()) {
case 401:
case 403:
// Authorization exceptions do not return an errors DTO, so we
// encapsulate a generic exception
exception = new AuthorizationException(defaultMessage, new HttpResponseException(command, response,
defaultMessage));
break;
case 404:
// TODO: get the exception to encapsulate from the returned error
// object
exception = new ResourceNotFoundException(defaultMessage);
break;
case 301:
// Moved resources in Abiquo should be handled with the
// ReturnMovedResource exception parser to return the moved
// entity.
exception = new HttpResponseException(command, response, defaultMessage);
break;
default:
// TODO: get the exception to encapsulate from the returned error
// object
exception = new HttpResponseException(response.getMessage(), command, response);
break;
}
} finally {
closeQuietly(response.getPayload());
command.setException(exception);
}
}