String requestLine = command.getCurrentRequest().getRequestLine();
String message = content != null ? content : String.format("%s -> %s", requestLine, response.getStatusLine());
switch (response.getStatusCode()) {
case 400:
if (message.indexOf("quota exceeded") != -1)
exception = new InsufficientResourcesException(message, exception);
else if (message.indexOf("has no fixed_ips") != -1)
exception = new IllegalStateException(message, exception);
else if (message.indexOf("already exists") != -1)
exception = new IllegalStateException(message, exception);
break;
case 401:
case 403:
exception = new AuthorizationException(message, exception);
break;
case 404:
if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
exception = new ResourceNotFoundException(message, exception);
}
break;
case 413:
if (content == null) {
exception = new InsufficientResourcesException(message, exception);
break;
}
exception = parseAndBuildRetryException(content, message, exception);
}
command.setException(exception);