String errorCode = parseErrorCode(in, xpath);
String errorType = asString("ErrorResponse/Error/Type", in, xpath);
String requestId = asString("ErrorResponse/RequestId", in, xpath);
String message = asString("ErrorResponse/Error/Message", in, xpath);
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;
}