本文整理了Java中com.amazonaws.AmazonServiceException.<init>()
方法的一些代码示例,展示了AmazonServiceException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AmazonServiceException.<init>()
方法的具体详情如下:
包路径:com.amazonaws.AmazonServiceException
类名称:AmazonServiceException
方法名:<init>
[英]Constructs a new AmazonServiceException with the specified message.
[中]使用指定的消息构造新的AmazonServiceException。
代码示例来源:origin: aws/aws-sdk-java
public List<String> getArgs() {
if (instanceGroup == null) {
throw new AmazonServiceException("InstanceGroup must not be null.");
}
if (instanceCount == null) {
throw new AmazonServiceException("InstanceCount must not be null.");
}
List<String> args = new ArrayList<String>();
args.add("--modify-instance-group");
args.add(instanceGroup);
args.add("--instance-count");
args.add(Integer.toString(instanceCount));
return args;
}
}
代码示例来源:origin: aws/aws-sdk-java
public List<String> getArgs() {
if (instanceGroup == null) {
throw new AmazonServiceException("InstanceGroup must not be null.");
}
if (instanceCount == null) {
throw new AmazonServiceException("InstanceCount must not be null.");
}
if (instanceType == null) {
throw new AmazonServiceException("InstanceType must not be null.");
}
List<String> args = new ArrayList<String>();
args.add("--add-instance-group");
args.add(instanceGroup);
args.add("--instance-count");
args.add(Integer.toString(instanceCount));
args.add("--instance-type");
args.add(instanceType);
return args;
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Create an AmazonServiceException using the chain of unmarshallers. This method will never
* return null, it will always return a valid AmazonServiceException
*
* @param errorCode
* Error code to find an appropriate unmarshaller
* @param jsonContent
* JsonContent of HTTP response
* @return AmazonServiceException
*/
private AmazonServiceException createException(String errorCode, JsonContent jsonContent) {
AmazonServiceException ase = unmarshallException(errorCode, jsonContent);
if (ase == null) {
ase = new AmazonServiceException(
"Unable to unmarshall exception response with the unmarshallers provided");
}
return ase;
}
代码示例来源:origin: aws/aws-sdk-java
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;
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Creates the final HadoopJarStepConfig once you are done configuring the step. You can use
* this as you would any other HadoopJarStepConfig.
* @return HadoopJarStepConfig configured to perform the specified actions.
*/
public HadoopJarStepConfig toHadoopJarStepConfig() {
if (args.size() == 0) {
throw new AmazonServiceException("Cannot create a ResizeJobFlowStep with no resize actions.");
}
if (wait == false) {
args.add("--no-wait");
}
if (onArrested != null) {
args.add("--on-arrested");
args.add(onArrested.toString());
}
if (onFailure != null) {
args.add("--on-failure");
args.add(onFailure.toString());
}
return new HadoopJarStepConfig()
.withJar("s3://" + bucket + "/libs/resize-job-flow/0.1/resize-job-flow.jar")
.withArgs(args);
}
代码示例来源:origin: Netflix/Priam
@Mock
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest var1)
throws SdkClientException, AmazonServiceException {
if (emulateError) throw new AmazonServiceException("Unable to reach AWS");
return null;
}
}
代码示例来源:origin: aws/aws-sdk-java
static Exception convert(BatchResultErrorEntry be) {
AmazonServiceException toReturn = new AmazonServiceException(be.getMessage());
toReturn.setErrorCode(be.getCode());
toReturn.setErrorType(be.isSenderFault() ? ErrorType.Client : ErrorType.Service);
toReturn.setServiceName("AmazonSQS");
return toReturn;
}
代码示例来源:origin: aws/aws-sdk-java
private AmazonServiceException handleAse(HttpResponse response) throws Exception {
final int statusCode = response.getStatusCode();
try {
return delegate.handle(response);
} catch(InterruptedException e) {
throw e;
} catch (Exception e) {
// If the errorResponseHandler doesn't work, then check for error responses that don't have any content
if (statusCode == 413) {
AmazonServiceException exception = new AmazonServiceException("Request entity too large");
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Client);
exception.setErrorCode("Request entity too large");
return exception;
} else if (statusCode >= 500 && statusCode < 600) {
AmazonServiceException exception = new AmazonServiceException(response.getStatusText());
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Service);
exception.setErrorCode(response.getStatusText());
return exception;
} else {
throw e;
}
}
}
代码示例来源:origin: apache/incubator-druid
if (objectSummary.getStorageClass() != null &&
StorageClass.fromValue(StringUtils.toUpperCase(objectSummary.getStorageClass())).equals(StorageClass.Glacier)) {
throw new AmazonServiceException(
StringUtils.format(
"Cannot move file[s3://%s/%s] of storage class glacier, skipping.",
代码示例来源:origin: aws-amplify/aws-sdk-android
@Override
public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception {
return new AmazonServiceException("TestException");
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Override
public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception {
return new AmazonServiceException("TestException");
}
代码示例来源:origin: aws-amplify/aws-sdk-android
private AmazonServiceException getServiceException(String errorCode) {
AmazonServiceException ase = new AmazonServiceException("some error message");
ase.setErrorCode(errorCode);
return ase;
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
private AmazonServiceException getServiceException(String errorCode) {
AmazonServiceException ase = new AmazonServiceException("some error message");
ase.setErrorCode(errorCode);
return ase;
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Override
public AmazonServiceException unmarshall(Node in) throws Exception {
called.add(true);
in = in.getFirstChild();
assertEquals(in.getNodeName(), "error");
assertEquals(
in.getTextContent(), "TestError");
AmazonServiceException ase = new AmazonServiceException("TestAse");
return ase;
}
};
代码示例来源:origin: aws-amplify/aws-sdk-android
static Exception convert(BatchResultErrorEntry be)
{
AmazonServiceException toReturn = new AmazonServiceException(be.getMessage());
toReturn.setErrorCode(be.getCode());
toReturn.setErrorType(be.isSenderFault() ? ErrorType.Client : ErrorType.Service);
toReturn.setServiceName("AmazonSQS");
return toReturn;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@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;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
assertSame(response, httpResponse);
AmazonServiceException ase = new AmazonServiceException("Test");
ase.setErrorCode("TestError");
ase.setErrorType(ErrorType.Service);
ase.setServiceName(request.getServiceName());
ase.setStatusCode(response.getStatusCode());
return ase;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testClockskewOffsetWithDateInBodyOfException() {
HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse")
.statusCode(400).build();
AmazonServiceException ase = new AmazonServiceException("(20041106T084937Z - 15)");
// assert date is > 10 years
int offset = client.parseClockSkewOffset(httpResponse, ase);
assertTrue(offset > 315400000);
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testClockskewOffsetWithBogusDateAsssumesOffsetIsZero() {
HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse")
.header("Date", "Sat, 064 Jann 20044 08:49:37 GMT")
.statusCode(400).build();
AmazonServiceException ase = new AmazonServiceException("ClockSkew");
// assert date is > 10 years
int offset = client.parseClockSkewOffset(httpResponse, ase);
assertEquals(offset, 0);
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testClockskewOffset() {
HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse")
.header("Date", "Sat, 06 Nov 2004 08:49:37 GMT")
.statusCode(400).build();
AmazonServiceException ase = new AmazonServiceException("ClockSkew");
// assert date is > 10 years
int offset = client.parseClockSkewOffset(httpResponse, ase);
assertTrue(offset > 315400000);
}
内容来源于网络,如有侵权,请联系作者删除!