當前位置: 首頁>>代碼示例>>Java>>正文


Java AmazonServiceException.setErrorCode方法代碼示例

本文整理匯總了Java中com.amazonaws.AmazonServiceException.setErrorCode方法的典型用法代碼示例。如果您正苦於以下問題:Java AmazonServiceException.setErrorCode方法的具體用法?Java AmazonServiceException.setErrorCode怎麽用?Java AmazonServiceException.setErrorCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.amazonaws.AmazonServiceException的用法示例。


在下文中一共展示了AmazonServiceException.setErrorCode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: modifyInstance_AmazonServiceException

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
@Ignore
@Test(expected = AbortException.class)
public void modifyInstance_AmazonServiceException() throws Exception {

    parameters.put(PropertyHandler.FLOW_STATE,
            new Setting(PropertyHandler.FLOW_STATE,
                    FlowState.MODIFICATION_REQUESTED.name()));
    parameters.put(PropertyHandler.OPERATION, new Setting(
            PropertyHandler.OPERATION, Operation.EC2_MODIFICATION.name()));

    AmazonServiceException ase = new AmazonServiceException("Test message");
    ase.setErrorCode("Unknown1234");
    ec2mock.createDescribeImagesException(ase);

    runUntilReady();
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:17,代碼來源:AWSControllerIT.java

示例2: 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

示例3: 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

示例4: 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

示例5: handleErrorResponse

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
private void handleErrorResponse(InputStream errorStream, int statusCode, String responseMessage) throws IOException {
    String errorCode = null;

    // Parse the error stream returned from the service.
    if(errorStream != null) {
        String errorResponse = IOUtils.toString(errorStream);

        try {
            JsonNode node = Jackson.jsonNodeOf(errorResponse);
            JsonNode code = node.get("code");
            JsonNode message = node.get("message");
            if (code != null && message != null) {
                errorCode = code.asText();
                responseMessage = message.asText();
            }
        } catch (Exception exception) {
            LOG.debug("Unable to parse error stream");
        }
    }

    AmazonServiceException ase = new AmazonServiceException(responseMessage);
    ase.setStatusCode(statusCode);
    ase.setErrorCode(errorCode);
    throw ase;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:26,代碼來源:EC2CredentialsUtils.java

示例6: createInstance_Authfailed

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
@Test(expected = SuspendException.class)
public void createInstance_Authfailed() throws Exception {

    parameters.put(PropertyHandler.FLOW_STATE,
            new Setting(PropertyHandler.FLOW_STATE,
                    FlowState.CREATION_REQUESTED.name()));
    parameters.put(PropertyHandler.OPERATION, new Setting(
            PropertyHandler.OPERATION, Operation.EC2_CREATION.name()));

    AmazonServiceException ase = new AmazonServiceException("Test message");
    ase.setErrorCode("AuthFailure");
    ec2mock.createDescribeImagesException(ase);

    runUntilReady();
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:16,代碼來源:AWSControllerIT.java

示例7: createInstance_AuthorizationFailed

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
@Test(expected = SuspendException.class)
public void createInstance_AuthorizationFailed() throws Exception {

    parameters.put(PropertyHandler.FLOW_STATE,
            new Setting(PropertyHandler.FLOW_STATE,
                    FlowState.CREATION_REQUESTED.name()));
    parameters.put(PropertyHandler.OPERATION, new Setting(
            PropertyHandler.OPERATION, Operation.EC2_CREATION.name()));

    AmazonServiceException ase = new AmazonServiceException("Test message");
    ase.setErrorCode("UnauthorizedOperation");
    ec2mock.createDescribeImagesException(ase);

    runUntilReady();
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:16,代碼來源:AWSControllerIT.java

示例8: createInstance_AmazonServiceException

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
@Test(expected = AbortException.class)
public void createInstance_AmazonServiceException() throws Exception {

    parameters.put(PropertyHandler.FLOW_STATE,
            new Setting(PropertyHandler.FLOW_STATE,
                    FlowState.CREATION_REQUESTED.name()));
    parameters.put(PropertyHandler.OPERATION, new Setting(
            PropertyHandler.OPERATION, Operation.EC2_CREATION.name()));

    AmazonServiceException ase = new AmazonServiceException("Test message");
    ase.setErrorCode("Unknown1234");
    ec2mock.createDescribeImagesException(ase);

    runUntilReady();
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:16,代碼來源:AWSControllerIT.java

示例9: executeServiceOperation_AmazonServiceException

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
@Test(expected = AbortException.class)
public void executeServiceOperation_AmazonServiceException()
        throws Exception {

    parameters.put(PropertyHandler.FLOW_STATE, new Setting(
            PropertyHandler.FLOW_STATE, FlowState.START_REQUESTED.name()));
    parameters.put(PropertyHandler.OPERATION, new Setting(
            PropertyHandler.OPERATION, Operation.EC2_OPERATION.name()));

    AmazonServiceException ase = new AmazonServiceException("Test message");
    ase.setErrorCode("Unknown1234");
    ec2mock.createStartInstanceException(ase);

    runUntilReady();
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:16,代碼來源:AWSControllerIT.java

示例10: testAccessFailure

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
@Test
public void testAccessFailure() throws Exception {
    final AmazonServiceException f = new AmazonServiceException("message", null);
    f.setStatusCode(403);
    f.setErrorCode("AccessDenied");
    assertTrue(new AmazonServiceExceptionMappingService().map(f) instanceof AccessDeniedException);
    f.setErrorCode("SignatureDoesNotMatch");
    assertTrue(new AmazonServiceExceptionMappingService().map(f) instanceof LoginFailureException);
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:10,代碼來源:AmazonServiceExceptionMappingServiceTest.java

示例11: handle

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
@Override
public AmazonServiceException handle(HttpResponse errorResponse) throws Exception {
    AmazonServiceException ase = createAse(errorResponse);
    if (ase == null) {
        throw new SdkClientException("Unable to unmarshall error response from service");
    }
    ase.setHttpHeaders(errorResponse.getHeaders());
    if (StringUtils.isNullOrEmpty(ase.getErrorCode())) {
        ase.setErrorCode(errorResponse.getStatusCode() + " " + errorResponse.getStatusText());
    }
    return ase;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:13,代碼來源:DefaultErrorResponseHandler.java

示例12: isThrottlingException_FalseWhenErrorAndStatusCodeDoNotMatch

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
@Test
public void isThrottlingException_FalseWhenErrorAndStatusCodeDoNotMatch() throws Exception {
    AmazonServiceException ase = new AmazonServiceException("msg");
    ase.setStatusCode(500);
    ase.setErrorCode("InternalFailure");
    assertFalse("InternalFailure error code should be false", RetryUtils.isThrottlingException(ase));
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:8,代碼來源:RetryUtilsTest.java

示例13: handle

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
@Override
public AmazonServiceException handle(
        com.amazonaws.http.HttpResponse response) throws Exception {
    AmazonServiceException ase = new AmazonServiceException("Fake service exception.");
    ase.setStatusCode(response.getStatusCode());
    ase.setErrorCode(response.getStatusText());
    return ase;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:9,代碼來源:RetryPolicyTestBase.java

示例14: getAse

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
private AmazonServiceException getAse(int statusCode, String errorCode) {
    AmazonServiceException exception = new AmazonServiceException(errorCode);
    exception.setStatusCode(statusCode);
    exception.setErrorCode(errorCode);
    return exception;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:7,代碼來源:SDKDefaultRetryConditionTest.java

示例15: isThrottlingException_TrueWhenErrorCodeMatchesKnownCodes

import com.amazonaws.AmazonServiceException; //導入方法依賴的package包/類
@Test
public void isThrottlingException_TrueWhenErrorCodeMatchesKnownCodes() throws Exception {
    AmazonServiceException ase = new AmazonServiceException("msg");
    ase.setErrorCode("ThrottlingException");
    assertTrue("ThrottlingException error code should be true", RetryUtils.isThrottlingException(ase));
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:7,代碼來源:RetryUtilsTest.java


注:本文中的com.amazonaws.AmazonServiceException.setErrorCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。