@Test public void test413WithRetryAfterExceptionFolsom() { fn.handleError(command, retryAfter); assertEquals(command.getException().getClass(), RetryAfterException.class); assertEquals(command.getException().getMessage(), "retry in 54 seconds"); }
public void handleError(HttpCommand command, HttpResponse response) { byte[] data = closeClientButKeepContentStream(response); String content = data != null ? emptyToNull(new String(data)) : null; Exception exception = content != null ? new HttpResponseException(command, response, content) : new HttpResponseException(command, response, logSensitiveInformation); 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 500: if (command.getCurrentRequest().getMethod().equals("POST") && message.indexOf("The server has either erred or is incapable of performing the requested operation.") != -1 && command.getCurrentRequest().getEndpoint().getPath().indexOf("os-floating-ips") != -1) { exception = new InsufficientResourcesException(message, exception); } break; case 413: if (content == null) { exception = new InsufficientResourcesException(message, exception); break; } exception = parseAndBuildRetryException(content, message, exception); } command.setException(exception); }
NovaErrorHandler implements HttpErrorHandler { public void handleError(HttpCommand command, HttpResponse response) { byte[] data = closeClientButKeepContentStream(response); String content = data != null ? emptyToNull(new String(data)) : null; Exception exception = content != null ? new HttpResponseException(command, response, content) : new HttpResponseException(command, response, logSensitiveInformation); 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 500: if (command.getCurrentRequest().getMethod().equals("POST") && message.indexOf("The server has either erred or is incapable of performing the requested operation.") != -1 && command.getCurrentRequest().getEndpoint().getPath().indexOf("os-floating-ips") != -1) { exception = new InsufficientResourcesException(message, exception); } break; case 413: if (content == null) { exception = new InsufficientResourcesException(message, exception); break; } exception = parseAndBuildRetryException(content, message, exception); } command.setException(exception); } }
NovaErrorHandler implements HttpErrorHandler { public void handleError(HttpCommand command, HttpResponse response) { byte[] data = closeClientButKeepContentStream(response); String content = data != null ? emptyToNull(new String(data)) : null; Exception exception = content != null ? new HttpResponseException(command, response, content) : new HttpResponseException(command, response, logSensitiveInformation); 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 500: if (command.getCurrentRequest().getMethod().equals("POST") && message.indexOf("The server has either erred or is incapable of performing the requested operation.") != -1 && command.getCurrentRequest().getEndpoint().getPath().indexOf("os-floating-ips") != -1) { exception = new InsufficientResourcesException(message, exception); } break; case 413: if (content == null) { exception = new InsufficientResourcesException(message, exception); break; } exception = parseAndBuildRetryException(content, message, exception); } command.setException(exception); } protected  NovaErrorHandler(HeaderToRetryAfterException retryAfterParser, OverLimitParser overLimitParser); @Inject  NovaErrorHandler(DateCodecFactory factory, OverLimitParser overLimitParser); }
NovaErrorHandler implements HttpErrorHandler { public void handleError(HttpCommand command, HttpResponse response) { byte[] data = closeClientButKeepContentStream(response); String content = data != null ? emptyToNull(new String(data)) : null; Exception exception = content != null ? new HttpResponseException(command, response, content) : new HttpResponseException(command, response, logSensitiveInformation); 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 500: if (command.getCurrentRequest().getMethod().equals("POST") && message.indexOf("The server has either erred or is incapable of performing the requested operation.") != -1 && command.getCurrentRequest().getEndpoint().getPath().indexOf("os-floating-ips") != -1) { exception = new InsufficientResourcesException(message, exception); } break; case 413: if (content == null) { exception = new InsufficientResourcesException(message, exception); break; } exception = parseAndBuildRetryException(content, message, exception); } command.setException(exception); } protected  NovaErrorHandler(HeaderToRetryAfterException retryAfterParser, OverLimitParser overLimitParser); @Inject  NovaErrorHandler(DateCodecFactory factory, OverLimitParser overLimitParser); void handleError(HttpCommand command, HttpResponse response); }
NovaErrorHandler implements HttpErrorHandler { public void handleError(HttpCommand command, HttpResponse response) { byte[] data = closeClientButKeepContentStream(response); String content = data != null ? emptyToNull(new String(data)) : null; Exception exception = content != null ? new HttpResponseException(command, response, content) : new HttpResponseException(command, response, logSensitiveInformation); 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 500: if (command.getCurrentRequest().getMethod().equals("POST") && message.indexOf("The server has either erred or is incapable of performing the requested operation.") != -1 && command.getCurrentRequest().getEndpoint().getPath().indexOf("os-floating-ips") != -1) { exception = new InsufficientResourcesException(message, exception); } break; case 413: if (content == null) { exception = new InsufficientResourcesException(message, exception); break; } exception = parseAndBuildRetryException(content, message, exception); } command.setException(exception); } protected  NovaErrorHandler(HeaderToRetryAfterException retryAfterParser, OverLimitParser overLimitParser); @Inject  NovaErrorHandler(DateCodecFactory factory, OverLimitParser overLimitParser); void handleError(HttpCommand command, HttpResponse response);  }