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


Java ErrorType类代码示例

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


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

示例1: unmarshall

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的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.ErrorType; //导入依赖的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_NullContent_ReturnsGenericAmazonServiceException

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
@Test
public void handle_NullContent_ReturnsGenericAmazonServiceException() throws Exception {
    httpResponse.setStatusCode(500);
    httpResponse.setContent(null);

    AmazonServiceException ase = responseHandler.handle(httpResponse);

    // We assert these common properties are set again to make sure that code path is exercised
    // for unknown AmazonServiceExceptions as well
    assertEquals(ERROR_CODE, ase.getErrorCode());
    assertEquals(500, ase.getStatusCode());
    assertEquals(SERVICE_NAME, ase.getServiceName());
    assertEquals(ErrorType.Service, ase.getErrorType());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:JsonErrorResponseHandlerTest.java

示例4: handle_UnmarshallerReturnsException_ClientErrorType

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
@Test
public void handle_UnmarshallerReturnsException_ClientErrorType() throws Exception {
    httpResponse.setStatusCode(400);
    expectUnmarshallerMatches();
    when(unmarshaller.unmarshall((JsonNode) anyObject()))
            .thenReturn(new CustomException("error"));

    AmazonServiceException ase = responseHandler.handle(httpResponse);

    assertEquals(ERROR_CODE, ase.getErrorCode());
    assertEquals(400, ase.getStatusCode());
    assertEquals(SERVICE_NAME, ase.getServiceName());
    assertEquals(ErrorType.Client, ase.getErrorType());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:JsonErrorResponseHandlerTest.java

示例5: handle_UnmarshallerReturnsException_ServiceErrorType

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
@Test
public void handle_UnmarshallerReturnsException_ServiceErrorType() throws Exception {
    httpResponse.setStatusCode(500);
    expectUnmarshallerMatches();
    when(unmarshaller.unmarshall((JsonNode) anyObject()))
            .thenReturn(new CustomException("error"));

    AmazonServiceException ase = responseHandler.handle(httpResponse);

    assertEquals(ErrorType.Service, ase.getErrorType());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:12,代码来源:JsonErrorResponseHandlerTest.java

示例6: getObjectMetadata

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
@Override
public ObjectMetadata getObjectMetadata(String bucketName, String key) throws AmazonServiceException {
  AmazonS3Exception exception = new AmazonS3Exception("Internal Error");
  exception.setStatusCode(500);
  exception.setErrorType(ErrorType.Service);
  throw exception;
}
 
开发者ID:HubSpot,项目名称:S3Decorators,代码行数:8,代码来源:HystrixS3DecoratorTest.java

示例7: getBucketInfo

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
private BucketInfo getBucketInfo(final String name) {
  final BucketInfo info = getBucketInfoOrNull(name);
  if (info == null) {
    final AmazonServiceException e = new AmazonServiceException("The specified bucket does not exist");
    e.setStatusCode(404);
    e.setErrorType(ErrorType.Client);
    e.setServiceName("Amazon S3");
    e.setErrorCode("NoSuchBucket");
    throw e;
  }
  return info;
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:13,代码来源:AmazonS3Stub.java

示例8: getObject

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
private S3ObjectInfo getObject(final String key) {
  final S3ObjectInfo info = getObjectOrNull(key);
  if (info == null) {
    final AmazonServiceException e = new AmazonServiceException("The specified key does not exist");
    e.setErrorCode("NoSuchKey");
    e.setErrorType(ErrorType.Client);
    e.setServiceName("Amazon S3");
    e.setStatusCode(404);
    throw e;
  }
  return info;
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:13,代码来源:AmazonS3Stub.java

示例9: listObjectsFailsIfNoBucket

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
@Test
public void listObjectsFailsIfNoBucket() {
  try {
    s3.listObjects("b");
  } catch (final AmazonServiceException e) {
    assertThat(e.getStatusCode(), is(404));
    assertThat(e.getErrorCode(), is("NoSuchBucket"));
    assertThat(e.getErrorType(), is(ErrorType.Client));
  }
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:11,代码来源:AmazonS3StubTest.java

示例10: getObjectWithInvalidBucket

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
@Test
public void getObjectWithInvalidBucket() {
  try {
    s3.getObject("b", "a");
  } catch (final AmazonServiceException e) {
    assertThat(e.getStatusCode(), is(404));
    assertThat(e.getErrorCode(), is("NoSuchBucket"));
    assertThat(e.getErrorType(), is(ErrorType.Client));
  }
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:11,代码来源:AmazonS3StubTest.java

示例11: getObjectWithInvalidKey

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
@Test
public void getObjectWithInvalidKey() {
  s3.createBucket("b");
  try {
    s3.getObject("b", "a");
  } catch (final AmazonServiceException e) {
    assertThat(e.getStatusCode(), is(404));
    assertThat(e.getErrorCode(), is("NoSuchKey"));
    assertThat(e.getErrorType(), is(ErrorType.Client));
  }
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:12,代码来源:AmazonS3StubTest.java

示例12: handle

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
public AmazonServiceException handle(HttpResponse response)
        throws Exception {
    JSONObject jsonBody = getBodyAsJson(response);
    Class<? extends AmazonServiceException> exceptionClass = exceptionClasses.get(response.getStatusCode());
    AmazonServiceException result;

    // Support other attribute names for the message?
    // TODO: Inspect exception type (caching details) and apply other values from the body
    String message = jsonBody.has("message") ? jsonBody.getString("message") : jsonBody.getString("Message");

    if (exceptionClass != null) {
        result = exceptionClass.getConstructor(String.class).newInstance(message);
    } else {
        result = AmazonServiceException.class.getConstructor(String.class).newInstance(message);
    }

    result.setServiceName(response.getRequest().getServiceName());
    result.setStatusCode(response.getStatusCode());

    if (response.getStatusCode() < 500) {
        result.setErrorType(ErrorType.Client);
    } else {
        result.setErrorType(ErrorType.Service);
    }

    for (Entry<String, String> headerEntry : response.getHeaders().entrySet()) {
        if (headerEntry.getKey().equalsIgnoreCase("X-Amzn-RequestId")) {
            result.setRequestId(headerEntry.getValue());
        }
    }

    return result;
}
 
开发者ID:awslabs,项目名称:aws-hal-client-java,代码行数:34,代码来源:StatusCodeErrorResponseHandler.java

示例13: getErrorTypeFromStatusCode

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
private ErrorType getErrorTypeFromStatusCode(int statusCode) {
    return statusCode < 500 ? ErrorType.Client : ErrorType.Service;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:4,代码来源:JsonErrorResponseHandler.java

示例14: shouldHandleServiceErrorForGetShardIterator

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
@Test
public void shouldHandleServiceErrorForGetShardIterator() {
  shouldHandleGetShardIteratorError(newAmazonServiceException(ErrorType.Service),
      TransientKinesisException.class);
}
 
开发者ID:apache,项目名称:beam,代码行数:6,代码来源:SimplifiedKinesisClientTest.java

示例15: shouldHandleClientErrorForGetShardIterator

import com.amazonaws.AmazonServiceException.ErrorType; //导入依赖的package包/类
@Test
public void shouldHandleClientErrorForGetShardIterator() {
  shouldHandleGetShardIteratorError(newAmazonServiceException(ErrorType.Client),
      RuntimeException.class);
}
 
开发者ID:apache,项目名称:beam,代码行数:6,代码来源:SimplifiedKinesisClientTest.java


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