Java Code Examples for com.amazonaws.AmazonServiceException.setServiceName()

The following are Jave code examples for showing how to use setServiceName() of the com.amazonaws.AmazonServiceException class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ibm-cos-sdk-java   File: JsonErrorResponseHandler.java   View Source Code Vote up 6 votes
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
    JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory);
    String errorCode = errorCodeParser.parseErrorCode(response, jsonContent);
    AmazonServiceException ase = createException(errorCode, jsonContent);

    // Jackson has special-casing for 'message' values when deserializing
    // Throwables, but sometimes the service passes the error message in
    // other JSON fields - handle it here.
    if (ase.getErrorMessage() == null) {
        ase.setErrorMessage(errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode()));
    }

    ase.setErrorCode(errorCode);
    ase.setServiceName(response.getRequest().getServiceName());
    ase.setStatusCode(response.getStatusCode());
    ase.setErrorType(getErrorTypeFromStatusCode(response.getStatusCode()));
    ase.setRawResponse(jsonContent.getRawContent());
    String requestId = getRequestIdFromHeaders(response.getHeaders());
    if (requestId != null) {
        ase.setRequestId(requestId);
    }
    ase.setHttpHeaders(response.getHeaders());
    return ase;
}
 
Example 2
Project: ibm-cos-sdk-java   File: AwsErrorResponseHandler.java   View Source Code Vote up 5 votes
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
    final AmazonServiceException ase = handleAse(response);
    ase.setStatusCode(response.getStatusCode());
    ase.setServiceName(response.getRequest().getServiceName());
    awsRequestMetrics.addPropertyWith(AWSRequestMetrics.Field.AWSRequestID, ase.getRequestId())
            .addPropertyWith(AWSRequestMetrics.Field.AWSErrorCode, ase.getErrorCode())
            .addPropertyWith(AWSRequestMetrics.Field.StatusCode, ase.getStatusCode());
    return ase;
}