Example usage for com.amazonaws AmazonServiceException getServiceName

List of usage examples for com.amazonaws AmazonServiceException getServiceName

Introduction

In this page you can find the example usage for com.amazonaws AmazonServiceException getServiceName.

Prototype

public String getServiceName() 

Source Link

Document

Returns the name of the service that sent this error response.

Usage

From source file:com.netflix.spinnaker.kork.aws.AwsMetricsSupport.java

License:Apache License

static String[] buildExceptionTags(AmazonWebServiceRequest originalRequest, Exception exception) {
    final AmazonServiceException ase = amazonServiceException(exception);

    String targetAccountId = DEFAULT_UNKNOWN;
    if (ase.getHttpHeaders() != null) {
        targetAccountId = ase.getHttpHeaders().get("targetAccountId");
    }/*www  .  ja v a2  s.  c  om*/

    return new String[] { "requestType", originalRequest.getClass().getSimpleName(), "statusCode",
            Integer.toString(ase.getStatusCode()), "errorCode",
            Optional.ofNullable(ase.getErrorCode()).orElse(DEFAULT_UNKNOWN), "serviceName",
            Optional.ofNullable(ase.getServiceName()).orElse(DEFAULT_UNKNOWN), "errorType",
            Optional.ofNullable(ase.getErrorType()).orElse(AmazonServiceException.ErrorType.Unknown).name(),
            "accountId", Optional.ofNullable(targetAccountId).orElse(DEFAULT_UNKNOWN) };
}

From source file:de.fischer.thotti.ec2.clients.EC2InternalClient.java

License:Apache License

/**
 * Handles an {@link AmazonServiceException} by logging the information
 * provided by Amazon AWS and turning the caught exception into
 * an {@link de.fischer.thotti.awscommon.AWSRemoteServiceException}.
 *///w ww .  j  a  v  a  2s .  co m
protected void handleAmazonServiceException(AmazonServiceException exception) throws AWSRemoteServiceException {
    if (logger.isErrorEnabled()) {
        String message = exception.getMessage();
        String code = exception.getErrorCode();
        AmazonServiceException.ErrorType type = exception.getErrorType();
        String requestId = exception.getRequestId();
        String service = exception.getServiceName();

        logger.error("Amazon AWS was not able to fullfil the last operation. "
                + "Error message = {}, error code = {}, error type = {}, " + "service = {}, requestID = {}",
                new Object[] { message, code, type, requestId, service });
    }

    throw new AWSRemoteServiceException(exception.getMessage());
}

From source file:jetbrains.buildServer.util.amazon.AWSException.java

License:Apache License

@Nullable
public static String getIdentity(@NotNull Throwable t) {
    if (t instanceof AWSException)
        return ((AWSException) t).getIdentity();
    if (t instanceof AmazonServiceException) {
        final AmazonServiceException ase = (AmazonServiceException) t;
        return ase.getServiceName() + ase.getErrorType().name() + String.valueOf(ase.getStatusCode())
                + ase.getErrorCode();/*from  ww  w . j  a  v  a2s.c o m*/
    }
    return null;
}

From source file:jetbrains.buildServer.util.amazon.AWSException.java

License:Apache License

@Nullable
public static String getDetails(@NotNull Throwable t) {
    if (t instanceof AWSException)
        return ((AWSException) t).getDetails();
    if (t instanceof AmazonServiceException) {
        final AmazonServiceException ase = (AmazonServiceException) t;
        return "\n" + "Service:             " + ase.getServiceName() + "\n" + "HTTP Status Code:    "
                + ase.getStatusCode() + "\n" + "AWS Error Code:      " + ase.getErrorCode() + "\n"
                + "Error Type:          " + ase.getErrorType() + "\n" + "Request ID:          "
                + ase.getRequestId();/*from   w ww . j  av a2 s  . co m*/
    }
    return null;
}

From source file:org.apache.hadoop.fs.s3a.S3AUtils.java

License:Apache License

/**
 * Get low level details of an amazon exception for logging; multi-line.
 * @param e exception//ww  w .  j a va  2s.c  o  m
 * @return string details
 */
public static String stringify(AmazonServiceException e) {
    StringBuilder builder = new StringBuilder(String.format("%s: %s error %d: %s; %s%s%n", e.getErrorType(),
            e.getServiceName(), e.getStatusCode(), e.getErrorCode(), e.getErrorMessage(),
            (e.isRetryable() ? " (retryable)" : "")));
    String rawResponseContent = e.getRawResponseContent();
    if (rawResponseContent != null) {
        builder.append(rawResponseContent);
    }
    return builder.toString();
}

From source file:org.apache.nifi.processors.aws.dynamodb.AbstractDynamoDBProcessor.java

License:Apache License

protected List<FlowFile> processServiceException(final ProcessSession session, List<FlowFile> flowFiles,
        AmazonServiceException exception) {
    List<FlowFile> failedFlowFiles = new ArrayList<>();
    for (FlowFile flowFile : flowFiles) {
        Map<String, String> attributes = new HashMap<>();
        attributes.put(DYNAMODB_ERROR_EXCEPTION_MESSAGE, exception.getMessage());
        attributes.put(DYNAMODB_ERROR_CODE, exception.getErrorCode());
        attributes.put(DYNAMODB_ERROR_MESSAGE, exception.getErrorMessage());
        attributes.put(DYNAMODB_ERROR_TYPE, exception.getErrorType().name());
        attributes.put(DYNAMODB_ERROR_SERVICE, exception.getServiceName());
        attributes.put(DYNAMODB_ERROR_RETRYABLE, Boolean.toString(exception.isRetryable()));
        attributes.put(DYNAMODB_ERROR_REQUEST_ID, exception.getRequestId());
        attributes.put(DYNAMODB_ERROR_STATUS_CODE, Integer.toString(exception.getStatusCode()));
        attributes.put(DYNAMODB_ERROR_EXCEPTION_MESSAGE, exception.getMessage());
        attributes.put(DYNAMODB_ERROR_RETRYABLE, Boolean.toString(exception.isRetryable()));
        flowFile = session.putAllAttributes(flowFile, attributes);
        failedFlowFiles.add(flowFile);//from w  w  w . j a v a2s  .c o  m
    }
    return failedFlowFiles;
}

From source file:org.xmlsh.aws.util.AWSCommand.java

License:BSD License

protected int handleException(AmazonServiceException e)
        throws InvalidArgumentException, XMLStreamException, SaxonApiException, CoreException, IOException {
    startResult();//w ww .  ja v a 2  s.  c  o  m
    startElement("service-exception");
    attribute("error-code", e.getErrorCode());
    attribute("error-message", e.getErrorMessage());
    attribute("service-name", e.getServiceName());
    attribute("request-id", e.getRequestId());
    attribute("status-code", e.getStatusCode());
    endElement();
    endResult();
    return e.getStatusCode();
}