Package com.amazonaws

Examples of com.amazonaws.AmazonServiceException


        } else {
            statusCode = statusLine.getStatusCode();
            reasonPhrase = statusLine.getReasonPhrase();
        }
        HttpResponse response = createResponse(method, request, apacheHttpResponse);
        AmazonServiceException exception = null;
        try {
            exception = errorResponseHandler.handle(response);
            if (requestLog.isDebugEnabled())
                requestLog.debug("Received error response: " + exception);
        } catch (Exception e) {
            // If the errorResponseHandler doesn't work, then check for error
            // responses that don't have any content
            if (statusCode == 413) {
                exception = new AmazonServiceException("Request entity too large");
                exception.setServiceName(request.getServiceName());
                exception.setStatusCode(statusCode);
                exception.setErrorType(ErrorType.Client);
                exception.setErrorCode("Request entity too large");
            } else if (statusCode == 503
                    && "Service Unavailable".equalsIgnoreCase(reasonPhrase)) {
                exception = new AmazonServiceException("Service unavailable");
                exception.setServiceName(request.getServiceName());
                exception.setStatusCode(statusCode);
                exception.setErrorType(ErrorType.Service);
                exception.setErrorCode("Service unavailable");
            } else if (e instanceof IOException) {
                throw (IOException) e;
            } else {
                String errorMessage = "Unable to unmarshall error response ("
                        + e.getMessage() + "). Response Code: "
                        + (statusLine == null ? "None" : statusCode)
                        + ", Response Text: " + reasonPhrase;
                throw new AmazonClientException(errorMessage, e);
            }
        }

        exception.setStatusCode(statusCode);
        exception.setServiceName(request.getServiceName());
        exception.fillInStackTrace();
        return exception;
    }
View Full Code Here


         * Currently we rely on the unmarshallers to return null if they can't
         * unmarshall the response, but we might need something a little more
         * sophisticated in the future.
         */
        for (Unmarshaller<AmazonServiceException, Node> unmarshaller : unmarshallerList) {
            AmazonServiceException ase = unmarshaller.unmarshall(document);
            if (ase != null) {
                ase.setStatusCode(errorResponse.getStatusCode());
                return ase;
            }
        }

        throw new AmazonClientException("Unable to unmarshall error response from service");
View Full Code Here

     * Used to create an {@link newAmazonServiceException} when we failed to
     * read the error response or parsed the error response as XML.
     */
    private AmazonServiceException newAmazonServiceException(String errmsg,
            HttpResponse httpResponse, Exception readFailure) {
        AmazonServiceException exception = new AmazonServiceException(errmsg, readFailure);
            final int statusCode = httpResponse.getStatusCode();
            exception.setErrorCode(statusCode + " " + httpResponse.getStatusText());
            exception.setErrorType(AmazonServiceException.ErrorType.Unknown);
            exception.setStatusCode(statusCode);
            return exception;
    }
View Full Code Here

            throw new AmazonClientException("Unable to parse error response: '" + streamContents + "'", e);
        }

        String errorTypeFromHeader = parseErrorTypeFromHeader(response);

        AmazonServiceException ase = runErrorUnmarshallers(response, jsonErrorMessage, errorTypeFromHeader);
        if (ase == null) return null;

        ase.setServiceName(response.getRequest().getServiceName());
        ase.setStatusCode(response.getStatusCode());
        if (response.getStatusCode() < 500) {
            ase.setErrorType(ErrorType.Client);
        } else {
            ase.setErrorType(ErrorType.Service);
        }

        for (Entry<String, String> headerEntry : response.getHeaders().entrySet()) {
            if (headerEntry.getKey().equalsIgnoreCase("X-Amzn-RequestId")) {
                ase.setRequestId(headerEntry.getValue());
            }
        }

        return ase;
    }
View Full Code Here

         * checks for the error type parsed either from response headers or the
         * content.
         */
        for (JsonErrorUnmarshaller unmarshaller : unmarshallerList) {
            if (unmarshaller.match(errorTypeFromHeader, json)) {
                AmazonServiceException ase = unmarshaller.unmarshall(json);
                ase.setStatusCode(errorResponse.getStatusCode());
                return ase;
            }
        }

        return null;
View Full Code Here

   * this as you would any other HadoopJarStepConfig.
   * @return HadoopJarStepConfig configured to perform the specified actions.
   */
  public HadoopJarStepConfig toHadoopJarStepConfig() {
    if (args.size() == 0) {
      throw new AmazonServiceException("Cannot create a ResizeJobFlowStep with no resize actions.");
    }

    if (wait == false) {
      args.add("--no-wait");
    }
View Full Code Here

      return this;
    }

    public List<String> getArgs() {
      if (instanceGroup == null) {
        throw new AmazonServiceException("InstanceGroup must not be null.");
      }
      if (instanceCount == null) {
        throw new AmazonServiceException("InstanceCount must not be null.");
      }

      List<String> args = new ArrayList<String>();
      args.add("--modify-instance-group");
      args.add(instanceGroup);
View Full Code Here

      return this;
    }

    public List<String> getArgs() {
      if (instanceGroup == null) {
        throw new AmazonServiceException("InstanceGroup must not be null.");
      }
      if (instanceCount == null) {
        throw new AmazonServiceException("InstanceCount must not be null.");
      }
      if (instanceType == null) {
        throw new AmazonServiceException("InstanceType must not be null.");
      }

      List<String> args = new ArrayList<String>();
      args.add("--add-instance-group");
      args.add(instanceGroup);
View Full Code Here

        return toReturn;
    }

    static Exception convert ( BatchResultErrorEntry be)
    {
        AmazonServiceException toReturn = new AmazonServiceException( be.getMessage());

        toReturn.setErrorCode(be.getCode());
        toReturn.setErrorType(be.isSenderFault() ? ErrorType.Client : ErrorType.Service);
        toReturn.setServiceName("AmazonSQS");

        return toReturn;

    }
View Full Code Here

            /**
             * Trigger the catch block in AmazonHttpClient.handleErrorResponse to handle 413 and 503 errors
             */
            throw new AmazonClientException("Neither error message nor error code is found in the error response payload.");
        } else {
            AmazonServiceException ase = newException(message);
            ase.setErrorCode(errorCode);
            return ase;
        }
    }
View Full Code Here

TOP

Related Classes of com.amazonaws.AmazonServiceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.