本文整理汇总了Java中com.amazonaws.AmazonServiceException.getErrorCode方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonServiceException.getErrorCode方法的具体用法?Java AmazonServiceException.getErrorCode怎么用?Java AmazonServiceException.getErrorCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.AmazonServiceException
的用法示例。
在下文中一共展示了AmazonServiceException.getErrorCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGetS3Object
import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
private S3Object doGetS3Object(URI uri, boolean isLightWeight) {
S3RegionalResource s3RegionalResource = new S3RegionalResource(uri);
String bucketName = s3RegionalResource.getBucketName();
String s3BucketKey = s3RegionalResource.getKey();
configureClient(s3RegionalResource);
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, s3BucketKey);
if (isLightWeight) {
//Skip content download
getObjectRequest.setRange(0, 0);
}
try {
return amazonS3Client.getObject(getObjectRequest);
} catch (AmazonServiceException e) {
String errorCode = e.getErrorCode();
if (null != errorCode && errorCode.equalsIgnoreCase("NoSuchKey")) {
return null;
}
throw ResourceExceptions.getFailed(uri, e);
}
}
示例2: map
import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public BackgroundException map(final AmazonClientException e) {
final StringBuilder buffer = new StringBuilder();
if(e instanceof AmazonServiceException) {
final AmazonServiceException failure = (AmazonServiceException) e;
this.append(buffer, failure.getErrorMessage());
switch(failure.getStatusCode()) {
case HttpStatus.SC_BAD_REQUEST:
switch(failure.getErrorCode()) {
case "Throttling":
return new RetriableAccessDeniedException(buffer.toString(), e);
case "AccessDeniedException":
return new AccessDeniedException(buffer.toString(), e);
case "UnrecognizedClientException":
return new LoginFailureException(buffer.toString(), e);
}
case HttpStatus.SC_FORBIDDEN:
switch(failure.getErrorCode()) {
case "SignatureDoesNotMatch":
return new LoginFailureException(buffer.toString(), e);
case "InvalidAccessKeyId":
return new LoginFailureException(buffer.toString(), e);
case "InvalidClientTokenId":
return new LoginFailureException(buffer.toString(), e);
case "InvalidSecurity":
return new LoginFailureException(buffer.toString(), e);
case "MissingClientTokenId":
return new LoginFailureException(buffer.toString(), e);
case "MissingAuthenticationToken":
return new LoginFailureException(buffer.toString(), e);
}
}
return new HttpResponseExceptionMappingService().map(new HttpResponseException(failure.getStatusCode(), buffer.toString()));
}
this.append(buffer, e.getMessage());
return this.wrap(e, buffer);
}