Source:
public void handleError(HttpCommand command, HttpResponse response) { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data) : null; Exception exception = message != null ? new HttpResponseException(command, response, message) : new HttpResponseException(command, response); message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); switch (response.getStatusCode()) { case 400: if (message.contains("RESOURCE_NOT_FOUND") || message.contains("OPERATION_NOT_SUPPORTED")) { exception = new ResourceNotFoundException(message, exception); } else if ((message.contains("CONFIGURATION_NOT_SUPPORTED") || message.contains("CPU_SPEED_NOT_AVAILABLE") || message.contains("INVALID_INPUT_DATA") || message.contains("ORGANIZATION_NOT_VERIFIED") || message.contains("SYSTEM_ERROR")) && !message.contains("RETRYABLE_SYSTEM_ERROR")) { exception = new IllegalStateException(message, exception); } else if (message.contains("RESOURCE_BUSY") || message.contains("UNEXPECTED_ERROR")) { exception = new ResourceNotFoundException(message, exception); } else if (message.contains("NAME_NOT_UNIQUE")) { exception = new ResourceAlreadyExistsException(message, exception); } break; case 401: exception = new AuthorizationException(message, exception); break; case 403: exception = new AuthorizationException(message, exception); break; case 404: if (!command.getCurrentRequest().getMethod().equals("DELETE")) { exception = new ResourceNotFoundException(message, exception); } break; } command.setException(exception); }

Target:
public void handleError(HttpCommand command, HttpResponse response) { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data) : null; Exception exception = message != null ? new HttpResponseException(command, response, message) : new HttpResponseException(command, response); message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); switch (response.getStatusCode()) { case 400: if (message.contains("RESOURCE_NOT_FOUND") || message.contains("OPERATION_NOT_SUPPORTED")) { exception = new ResourceNotFoundException(message, exception); } else if (message.contains("INVALID_INPUT_DATA") || message.contains("ORGANIZATION_NOT_VERIFIED") || (message.contains("SYSTEM_ERROR") && !message.contains("RETRYABLE_SYSTEM_ERROR")) || message .contains("CPU_SPEED_NOT_AVAILABLE") || message.contains("CONFIGURATION_NOT_SUPPORTED")) { exception = new IllegalStateException(message, exception); } else if (message.contains("RESOURCE_BUSY") || message.contains("UNEXPECTED_ERROR")) { exception = new ResourceNotFoundException(message, exception); } else if (message.contains("NAME_NOT_UNIQUE")) { exception = new ResourceAlreadyExistsException(message, exception); } break; case 401: exception = new AuthorizationException(message, exception); break; case 403: exception = new AuthorizationException(message, exception); break; case 404: if (!command.getCurrentRequest().getMethod().equals("DELETE")) { exception = new ResourceNotFoundException(message, exception); } break; } command.setException(exception); }