@Resource
protected Logger logger = Logger.NULL;
public static final Pattern RESOURCE_PATTERN = Pattern.compile(".*/v[^/]+/([^/]+)/([0-9]+)");
public void handleError(HttpCommand command, HttpResponse response) {
Exception exception = new HttpResponseException(command, response);
try {
String content = parseErrorFromContentOrNull(command, response);
if (content != null)
exception = new HttpResponseException(command, response, content);
if (response.getMessage() != null
&& ((response.getMessage().indexOf("because there is a pending task running") != -1)
|| (response.getMessage().indexOf("because it is already powered off") != -1)
|| (response.getMessage().indexOf("exists") != -1)))
exception = new IllegalStateException(response.getMessage(), exception);
else if (response.getMessage() != null
&& ((response.getMessage().indexOf("There are no additional Public IPs available") != -1)))
exception = new InsufficientResourcesException(response.getMessage(), exception);
else
switch (response.getStatusCode()) {
case 400:
exception = new IllegalArgumentException(response.getMessage(), exception);
break;
case 401:
exception = new AuthorizationException(exception.getMessage(), exception);
break;
case 403: // TODO temporary as terremark mistakenly uses this for vApp
// not found.
case 404:
String path = command.getCurrentRequest().getEndpoint().getPath();