Package com.amazonaws

Examples of com.amazonaws.AmazonServiceException


      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


        String errorCode = parseErrorCode(in);
        String errorType = XpathUtils.asString("ErrorResponse/Error/Type", in);
        String requestId = XpathUtils.asString("ErrorResponse/RequestId", in);
        String message = XpathUtils.asString("ErrorResponse/Error/Message", in);

        AmazonServiceException ase = newException(message);
        ase.setErrorCode(errorCode);
        ase.setRequestId(requestId);

        if (errorType == null) {
            ase.setErrorType(ErrorType.Unknown);
        } else if (errorType.equalsIgnoreCase("Receiver")) {
            ase.setErrorType(ErrorType.Service);
        } else if (errorType.equalsIgnoreCase("Sender")) {
            ase.setErrorType(ErrorType.Client);
        }

        return ase;
    }
View Full Code Here

        String message = XpathUtils.asString("Response/Errors/Error/Message", in);
        String requestId = XpathUtils.asString("Response/RequestID", in);
        String errorType = XpathUtils.asString("Response/Errors/Error/Type", in);

        Constructor<? extends AmazonServiceException> constructor = exceptionClass.getConstructor(String.class);
        AmazonServiceException ase = constructor.newInstance(message);
        ase.setErrorCode(errorCode);
        ase.setRequestId(requestId);

        if (errorType == null) {
            ase.setErrorType(ErrorType.Unknown);
        } else if (errorType.equalsIgnoreCase("server")) {
            ase.setErrorType(ErrorType.Service);
        } else if (errorType.equalsIgnoreCase("client")) {
            ase.setErrorType(ErrorType.Client);
        }

        return ase;
    }
View Full Code Here

        String message = "";
        if (json.has("message")) {
            message = json.getString("message");
        }

        AmazonServiceException ase = newException(message);

        String errorCode = parseErrorCode(json);
        ase.setErrorCode(errorCode);
        return ase;
    }
View Full Code Here

    }

    @Override
    public ObjectListing listObjects(ListObjectsRequest listObjectsRequest) throws AmazonClientException, AmazonServiceException {
        if ("nonExistingBucket".equals(listObjectsRequest.getBucketName()) && !nonExistingBucketCreated) {
            AmazonServiceException ex = new AmazonServiceException("Unknow bucket");
            ex.setStatusCode(404);
            throw ex;
        }
       
        ObjectListing objectListing = new ObjectListing();
        int capacity = listObjectsRequest.getMaxKeys();
View Full Code Here

                .addPropertyWith(AWSRequestID, null)
                ;
            return null; // => retry
        }
        p.leaveHttpConnectionOpen = errorResponseHandler.needsConnectionLeftOpen();
        final AmazonServiceException ase = handleErrorResponse(request,
                errorResponseHandler, p.apacheRequest, p.apacheResponse);
        awsRequestMetrics
            .addPropertyWith(AWSRequestID, ase.getRequestId())
            .addPropertyWith(AWSErrorCode, ase.getErrorCode())
            .addPropertyWith(StatusCode, ase.getStatusCode());
        if (!shouldRetry(request.getOriginalRequest(),
                         p.apacheRequest,
                         ase,
                         p.requestCount,
                         config.getRetryPolicy())) {
View Full Code Here

    private <T extends Throwable> T captureExceptionMetrics(T t,
            AWSRequestMetrics awsRequestMetrics) {
        awsRequestMetrics.incrementCounterWith(Exception)
                         .addProperty(Exception, t);
        if (t instanceof AmazonServiceException) {
            AmazonServiceException ase = (AmazonServiceException) t;
            if (RetryUtils.isThrottlingException(ase)) {
                awsRequestMetrics.incrementCounterWith(ThrottleException)
                                 .addProperty(ThrottleException, ase);
            }
        }
View Full Code Here

        } 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

                .addPropertyWith(AWSRequestID, null)
                ;
            return null; // => retry
        }
        p.leaveHttpConnectionOpen = errorResponseHandler.needsConnectionLeftOpen();
        final AmazonServiceException ase = handleErrorResponse(request,
                errorResponseHandler, p.apacheRequest, p.apacheResponse);
        awsRequestMetrics
            .addPropertyWith(AWSRequestID, ase.getRequestId())
            .addPropertyWith(AWSErrorCode, ase.getErrorCode())
            .addPropertyWith(StatusCode, ase.getStatusCode());
        // Check whether we should internally retry the auth error
        p.authRetryParam = null;
        AuthErrorRetryStrategy authRetry = execContext.getAuthErrorRetryStrategy();
        if ( authRetry != null ) {
            p.authRetryParam = authRetry.shouldRetryWithAuthParam(request, ase);
View Full Code Here

    private <T extends Throwable> T captureExceptionMetrics(T t,
            AWSRequestMetrics awsRequestMetrics) {
        awsRequestMetrics.incrementCounterWith(Exception)
                         .addProperty(Exception, t);
        if (t instanceof AmazonServiceException) {
            AmazonServiceException ase = (AmazonServiceException) t;
            if (RetryUtils.isThrottlingException(ase)) {
                awsRequestMetrics.incrementCounterWith(ThrottleException)
                                 .addProperty(ThrottleException, 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.