当前位置: 首页>>代码示例>>Java>>正文


Java AmazonServiceException.getErrorCode方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:S3Client.java

示例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);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:38,代码来源:AmazonServiceExceptionMappingService.java


注:本文中的com.amazonaws.AmazonServiceException.getErrorCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。