public void handleError()

in oneandone/src/main/java/org/apache/jclouds/oneandone/rest/handlers/OneAndOneHttpErrorHandler.java [36:79]


   public void handleError(final HttpCommand command, final HttpResponse response) {
      Exception exception = null;
      try {
         switch (response.getStatusCode()) {
            case 400:
            case 405:
               exception = new IllegalArgumentException(response.getMessage(), exception);
               break;
            case 401:
               exception = new AuthorizationException("This request requires authentication.", exception);
               break;
            case 402:
            case 409:
               exception = new IllegalStateException(response.getMessage(), exception);
               break;
            case 404:
            case 410:
               if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
                  exception = new ResourceNotFoundException(response.getMessage(), exception);
               }
               break;
            case 413:
            case 429:
               exception = new OneAndOneRateLimitExceededException(response);
               break;
            case 503:
               // if nothing (default message was OK) was parsed from command executor, assume it was an 503 (Maintenance) html response.
               if (response.getMessage().equals("OK")) {
                  exception = new HttpResponseException("The OneAndOne team is currently carrying out maintenance.", command, response);
               } else {
                  exception = new InsufficientResourcesException(response.getMessage(), exception);
               }
               break;
            default:
               String message = parseMessage(response);
               exception = message == null ? new HttpResponseException(command, response) : new HttpResponseException(
                       command, response, message);
               break;
         }
      } finally {
         closeQuietly(response.getPayload());
         command.setException(exception);
      }
   }