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


Java AmazonServiceException.setErrorType方法代码示例

本文整理汇总了Java中com.amazonaws.AmazonServiceException.setErrorType方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonServiceException.setErrorType方法的具体用法?Java AmazonServiceException.setErrorType怎么用?Java AmazonServiceException.setErrorType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.AmazonServiceException的用法示例。


在下文中一共展示了AmazonServiceException.setErrorType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unmarshall

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
/**
 * @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object)
 */
public AmazonServiceException unmarshall(Node in) throws Exception {
    XPath xpath = xpath();
    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;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:25,代码来源:StandardErrorUnmarshaller.java

示例2: unmarshall

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@Override
public AmazonServiceException unmarshall(Node in) throws Exception {
    XPath xpath = xpath();
    String errorCode = parseErrorCode(in, xpath);
    String message = asString("Response/Errors/Error/Message", in, xpath);
    String requestId = asString("Response/RequestID", in, xpath);
    String errorType = asString("Response/Errors/Error/Type", in, xpath);

    Constructor<? extends AmazonServiceException> constructor = exceptionClass.getConstructor(String.class);
    AmazonServiceException ase = constructor.newInstance(message);
    ase.setErrorCode(errorCode);
    ase.setRequestId(requestId);

    if (errorType == null) {
        ase.setErrorType(ErrorType.Unknown);
    } else if (errorType.equalsIgnoreCase("server")) {
        ase.setErrorType(ErrorType.Service);
    } else if (errorType.equalsIgnoreCase("client")) {
        ase.setErrorType(ErrorType.Client);
    }

    return ase;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:24,代码来源:LegacyErrorUnmarshaller.java

示例3: handle

import com.amazonaws.AmazonServiceException; //导入方法依赖的package包/类
@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;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:JsonErrorResponseHandler.java


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