List of usage examples for com.amazonaws AmazonServiceException getErrorCode
public String getErrorCode()
From source file:org.xmlsh.aws.gradle.ec2.AmazonEC2RevokeSecurityGroupIngressTask.java
License:BSD License
@TaskAction public void revokeIngress() { // to enable conventionMappings feature String groupId = getGroupId(); Object ipPermissions = getIpPermissions(); if (groupId == null) throw new GradleException("groupId is not specified"); if (ipPermissions == null) throw new GradleException("ipPermissions is not specified"); AmazonEC2PluginExtension ext = getProject().getExtensions().getByType(AmazonEC2PluginExtension.class); AmazonEC2 ec2 = ext.getClient();// www . j a v a 2 s . c om try { ec2.revokeSecurityGroupIngress(new RevokeSecurityGroupIngressRequest().withGroupId(groupId) .withIpPermissions(parse(ipPermissions))); } catch (AmazonServiceException e) { if (e.getErrorCode().equals("InvalidPermission.NotFound")) { getLogger().warn(e.getMessage()); } else { throw e; } } }
From source file:org.xmlsh.aws.util.AWSCommand.java
License:BSD License
protected int handleException(AmazonServiceException e) throws InvalidArgumentException, XMLStreamException, SaxonApiException, CoreException, IOException { startResult();//w w w . j a v a 2 s. co m startElement("service-exception"); attribute("error-code", e.getErrorCode()); attribute("error-message", e.getErrorMessage()); attribute("service-name", e.getServiceName()); attribute("request-id", e.getRequestId()); attribute("status-code", e.getStatusCode()); endElement(); endResult(); return e.getStatusCode(); }
From source file:org.zalando.stups.fullstop.plugin.SaveSecurityGroupsPlugin.java
License:Apache License
private List<String> listS3Objects(String bucketName, String prefix) { final List<String> commonPrefixes = Lists.newArrayList(); AmazonS3Client s3client = new AmazonS3Client(); try {/*from w w w . j a va 2s .c o m*/ System.out.println("Listing objects"); ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withDelimiter("/") .withBucketName(bucketName).withPrefix(prefix); ObjectListing objectListing; do { objectListing = s3client.listObjects(listObjectsRequest); commonPrefixes.addAll(objectListing.getCommonPrefixes()); for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { System.out.println( " - " + objectSummary.getKey() + " " + "(size = " + objectSummary.getSize() + ")"); } listObjectsRequest.setMarker(objectListing.getNextMarker()); } while (objectListing.isTruncated()); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, " + "which means your request made it " + "to Amazon S3, but was rejected with an error response " + "for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, " + "which means the client encountered " + "an internal error while trying to communicate" + " with S3, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } return commonPrefixes; }
From source file:org.zalando.stups.fullstop.s3.S3Writer.java
License:Apache License
public void putObjectToS3(String bucket, String fileName, String keyName, ObjectMetadata metadata, InputStream stream) {/* www . j a v a 2 s . c o m*/ AmazonS3 s3client = new AmazonS3Client(); try { logger.info("Uploading a new object to S3 from a file"); s3client.putObject( new PutObjectRequest(bucket, Paths.get(keyName, fileName).toString(), stream, metadata)); } catch (AmazonServiceException ase) { logger.error("Caught an AmazonServiceException, which " + "means your request made it " + "to Amazon S3, but was rejected with an error response" + " for some reason."); logger.error("Error Message: " + ase.getMessage()); logger.error("HTTP Status Code: " + ase.getStatusCode()); logger.error("AWS Error Code: " + ase.getErrorCode()); logger.error("Error Type: " + ase.getErrorType()); logger.error("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { logger.error("Caught an AmazonClientException, which " + "means the client encountered " + "an internal error while trying to " + "communicate with S3, " + "such as not being able to access the network."); logger.error("Error Message: " + ace.getMessage()); } }
From source file:oulib.aws.s3.S3TiffMetadataProcessorThread.java
@Override public void run() { String sourceBucketName = bookInfo.getBucketSourceName(); String targetBucketName = bookInfo.getBucketTargetName(); String bookName = bookInfo.getBookName(); String bucketFolder = S3Util.S3_TIFF_METADATA_PROCESS_OUTPUT + File.separator + sourceBucketName; File bucketFolderFile = new File(bucketFolder); if (!bucketFolderFile.exists() || !bucketFolderFile.isDirectory()) { bucketFolderFile.mkdirs();//from w ww .j a v a 2 s .co m } String bookPath = bucketFolder + File.separator + bookName; File bookFile = new File(bookPath); if (!bookFile.exists()) { bookFile.mkdir(); } try { // Every book has a folder in the target bucket: Map targetBucketKeyMap = S3Util.getBucketObjectKeyMap(targetBucketName, bookName, s3client); if (!S3Util.folderExitsts(bookName, targetBucketKeyMap)) { S3Util.createFolder(targetBucketName, bookName, s3client); } for (String key : tiffList) { if (key.contains(".tif") && matchS3ObjKeyWithFilter(key, filter) && targetBucketKeyMap.containsKey(key) && !targetBucketKeyMap.containsKey(key.split(".tif")[0] + "-copied.tif")) { S3Object objectSource = s3client.getObject(new GetObjectRequest(sourceBucketName, key)); S3Object objectTarget = s3client.getObject(new GetObjectRequest(targetBucketName, key)); output += ("Start to copy metadata from the source object " + sourceBucketName + "/" + key + " to target object " + targetBucketName + "/" + key + "\n"); System.out.println("Start to copy metadata from the source object " + sourceBucketName + "/" + key + " to target object " + targetBucketName + "/" + key + "\n"); S3Util.copyS3ObjectTiffMetadata(s3client, objectSource, objectTarget); System.out.println("Finished copy metadata for the object with key=" + key + "\n"); output += "Finished copy metadata for the object with key=" + key + "\n"; try { objectSource.close(); objectTarget.close(); } catch (IOException ex) { Logger.getLogger(S3TiffProcessorThread.class.getName()).log(Level.SEVERE, null, ex); } } } System.out.println(Thread.currentThread().getName() + "'s job is done!"); } catch (AmazonServiceException ase) { output += "Caught an AmazonServiceException, which means your request made it to Amazon S3, but was rejected with an error response for some reason.\n"; output += "Error Message: " + ase.getMessage(); output += "HTTP Status Code: " + ase.getStatusCode(); output += "AWS Error Code: " + ase.getErrorCode(); output += "Error Type: " + ase.getErrorType(); output += "Request ID: " + ase.getRequestId(); System.out.println( "Caught an AmazonServiceException, which means your request made it to Amazon S3, but was rejected with an error response for some reason.\n"); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { output += "Caught an AmazonClientException, which means the client encountered an internal error while trying to communicate with S3, \nsuch as not being able to access the network.\n"; output += "Error Message: " + ace.getMessage(); System.out.println( "Caught an AmazonClientException, which means the client encountered an internal error while trying to communicate with S3, \nsuch as not being able to access the network.\n"); System.out.println("Error Message: " + ace.getMessage()); } finally { outputToFile(bookPath + File.separator + filter + ".txt"); } }
From source file:oulib.aws.s3.S3TiffProcessor.java
/** * * @param bookInfo : contains the information of the source bucket name, target bucket name, and the name of the book * @param context : lambda function runtime context * @return :/*from w w w . ja v a 2 s.c o m*/ * */ @Override public String handleRequest(S3BookInfo bookInfo, Context context) { AmazonS3 s3client = new AmazonS3Client(); Region usEast = Region.getRegion(Regions.US_EAST_1); s3client.setRegion(usEast); try { String sourceBucketName = bookInfo.getBucketSourceName(); String targetBucketName = bookInfo.getBucketTargetName(); String bookName = bookInfo.getBookName(); // Every book has a folder in the target bucket: Map targetBucketKeyMap = S3Util.getBucketObjectKeyMap(targetBucketName, bookName, s3client); if (!S3Util.folderExitsts(bookName, targetBucketKeyMap)) { S3Util.createFolder(targetBucketName, bookName, s3client); } final ListObjectsV2Request req = new ListObjectsV2Request().withBucketName(sourceBucketName) .withPrefix(bookName + "/data/"); ListObjectsV2Result result; do { result = s3client.listObjectsV2(req); for (S3ObjectSummary objectSummary : result.getObjectSummaries()) { String key = objectSummary.getKey(); if (key.endsWith(".tif") && !targetBucketKeyMap.containsKey(key + ".tif")) { S3Object object = s3client.getObject(new GetObjectRequest(sourceBucketName, key)); System.out.println("Start to generate smaller tif image for the object " + key); S3Util.generateSmallTiffWithTargetSize(s3client, object, targetBucketName, bookInfo.getCompressionSize()); // S3Util.copyS3ObjectTiffMetadata(s3client, object, s3client.getObject(new GetObjectRequest(targetBucketName, key)), targetBucketName, key+".tif"); System.out.println("Finished to generate smaller tif image for the object " + key + ".tif"); // break; } } System.out.println("Next Continuation Token : " + result.getNextContinuationToken()); req.setContinuationToken(result.getNextContinuationToken()); } while (result.isTruncated() == true); } catch (AmazonServiceException ase) { System.out.println( "Caught an AmazonServiceException, which means your request made it to Amazon S3, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println( "Caught an AmazonClientException, which means the client encountered an internal error while trying to communicate with S3, \nsuch as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } return null; }
From source file:oulib.aws.s3.S3TiffProcessorThread.java
@Override public void run() { String sourceBucketName = bookInfo.getBucketSourceName(); String targetBucketName = bookInfo.getBucketTargetName(); String bookName = bookInfo.getBookName(); String bucketFolder = S3Util.S3_SMALL_DERIVATIVE_OUTPUT + File.separator + sourceBucketName; File bucketFolderFile = new File(bucketFolder); if (!bucketFolderFile.exists() || !bucketFolderFile.isDirectory()) { bucketFolderFile.mkdirs();//from w ww. jav a 2 s . c o m } String bookPath = bucketFolder + File.separator + bookName; File bookFile = new File(bookPath); if (!bookFile.exists()) { bookFile.mkdir(); } try { // Every book has a folder in the target bucket: Map targetBucketKeyMap = S3Util.getBucketObjectKeyMap(targetBucketName, bookName, s3client); if (!S3Util.folderExitsts(bookName, targetBucketKeyMap)) { S3Util.createFolder(targetBucketName, bookName, s3client); } // final ListObjectsV2Request req = new ListObjectsV2Request().withBucketName(sourceBucketName).withPrefix(bookName + "/data/"); // ListObjectsV2Result result; // do { // result = s3client.listObjectsV2(req); for (String key : tiffList) { // String key = objectSummary.getKey(); // if(key.contains(".tif") && key.contains(filter) && !targetBucketKeyMap.containsKey(key+".tif")){ if (key.contains(".tif") && matchS3ObjKeyWithFilter(key, filter) && !targetBucketKeyMap.containsKey(key + ".tif")) { S3Object object = s3client.getObject(new GetObjectRequest(sourceBucketName, key)); output += ("Start to generate smaller tif image for the object " + key + "\n"); System.out.println("Start to generate smaller tif image for the object " + key + "\n"); // System.out.println("Working on the object "+key); S3Util.generateSmallTiffWithTargetSize(s3client, object, targetBucketName, bookInfo.getCompressionSize()); // S3Util.copyS3ObjectTiffMetadata(s3client, object, s3client.getObject(new GetObjectRequest(targetBucketName, key)), targetBucketName, key+".tif"); System.out.println("Finished to generate smaller tif image for the object " + key + "\n"); output += "Finished to generate smaller tif image for the object " + key + "\n"; try { object.close(); } catch (IOException ex) { Logger.getLogger(S3TiffProcessorThread.class.getName()).log(Level.SEVERE, null, ex); } } } // output += "Next Continuation Token : " + result.getNextContinuationToken(); System.out.println(Thread.currentThread().getName() + "'s job is done!"); // req.setContinuationToken(result.getNextContinuationToken()); // } while(result.isTruncated() == true ); } catch (AmazonServiceException ase) { output += "Caught an AmazonServiceException, which means your request made it to Amazon S3, but was rejected with an error response for some reason.\n"; output += "Error Message: " + ase.getMessage(); output += "HTTP Status Code: " + ase.getStatusCode(); output += "AWS Error Code: " + ase.getErrorCode(); output += "Error Type: " + ase.getErrorType(); output += "Request ID: " + ase.getRequestId(); System.out.println( "Caught an AmazonServiceException, which means your request made it to Amazon S3, but was rejected with an error response for some reason.\n"); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { output += "Caught an AmazonClientException, which means the client encountered an internal error while trying to communicate with S3, \nsuch as not being able to access the network.\n"; output += "Error Message: " + ace.getMessage(); System.out.println( "Caught an AmazonClientException, which means the client encountered an internal error while trying to communicate with S3, \nsuch as not being able to access the network.\n"); System.out.println("Error Message: " + ace.getMessage()); } finally { outputToFile(bookPath + File.separator + filter + ".txt"); } }
From source file:oulib.aws.s3.S3Util.java
public static void generateTifDerivativesByS3Bucket(AmazonS3 s3client, S3BookInfo bookInfo) { String sourceBucketName = bookInfo.getBucketSourceName(); String targetBucketName = bookInfo.getBucketTargetName(); String bookName = bookInfo.getBookName(); try {/*from w w w .ja v a 2 s . c om*/ // Every book has a folder in the target bucket: Map targetBucketKeyMap = S3Util.getBucketObjectKeyMap(targetBucketName, bookName, s3client); if (!S3Util.folderExitsts(bookName, targetBucketKeyMap)) { S3Util.createFolder(targetBucketName, bookName, s3client); } final ListObjectsV2Request req = new ListObjectsV2Request().withBucketName(sourceBucketName) .withPrefix(bookName + "/data/"); ListObjectsV2Result result; do { result = s3client.listObjectsV2(req); for (S3ObjectSummary objectSummary : result.getObjectSummaries()) { String key = objectSummary.getKey(); if (key.contains(".tif") && (key.contains("047") || key.contains("049") || key.contains("054")) && !targetBucketKeyMap.containsKey(key + ".tif")) { S3Object object = s3client.getObject(new GetObjectRequest(sourceBucketName, key)); System.out.println("Start to generate smaller tif image for the object " + key + "\n"); S3Util.generateSmallTiffWithTargetSize(s3client, object, targetBucketName, bookInfo.getCompressionSize()); // S3Util.copyS3ObjectTiffMetadata(s3client, object, s3client.getObject(new GetObjectRequest(targetBucketName, key)), targetBucketName, key+".tif"); System.out.println("Finished to generate smaller tif image for the object " + key + "\n"); // break; } } System.out.println("Next Continuation Token : " + result.getNextContinuationToken() + "\n"); req.setContinuationToken(result.getNextContinuationToken()); } while (result.isTruncated() == true); } catch (AmazonServiceException ase) { System.out.println( "Caught an AmazonServiceException, which means your request made it to Amazon S3, but was rejected with an error response for some reason.\n"); System.out.println("Error Message: " + ase.getMessage() + "\n"); System.out.println("HTTP Status Code: " + ase.getStatusCode() + "\n"); System.out.println("AWS Error Code: " + ase.getErrorCode() + "\n"); System.out.println("Error Type: " + ase.getErrorType() + "\n"); System.out.println("Request ID: " + ase.getRequestId() + "\n"); } catch (AmazonClientException ace) { System.out.println( "Caught an AmazonClientException, which means the client encountered an internal error while trying to communicate with S3, \nsuch as not being able to access the network.\n"); System.out.println("Error Message: " + ace.getMessage() + "\n"); } }
From source file:pa3.RemoteClientSQS.java
License:Open Source License
public static void main(String[] args) throws Exception { initSQSandDynamoDB();// w w w. j av a 2 s .c o m double startTime, endTime, totalTime; // String fileName = // "C:/Cloud/Assignment/LocalQueueAsst3/src/cloud/asst3/queue/10KSleepTasks.txt"; // int noOfThreads = 16 ; // String localOrRemote = "REMOTE"; // String clientOrWorker = "CLIENT"; String fileName = args[4]; String requestQueueName = "MyRequestQueue" + args[2]; String responseQueueName = "MyResponseQueue" + args[2]; String clientOrWorker = args[0]; System.out.println("==========================================="); System.out.println("Lets get started with Amazon SQS"); System.out.println("===========================================\n"); try { // Create a queue System.out.println("Creating a new SQS queue called MyRequestQueue.\n"); CreateQueueRequest createRequestQueue = new CreateQueueRequest(requestQueueName); String myRequestQueueUrl = sqs.createQueue(createRequestQueue).getQueueUrl(); System.out.println("Creating a new SQS queue called MyResponseQueue.\n"); CreateQueueRequest createResponseQueue = new CreateQueueRequest(responseQueueName); String myResponseQueueUrl = sqs.createQueue(createResponseQueue).getQueueUrl(); // List queues System.out.println("Listing all queues in your account.\n"); for (String queueUrl : sqs.listQueues().getQueueUrls()) { System.out.println(" QueueUrl: " + queueUrl); } // Send a message System.out.println("Sending a message to " + requestQueueName); int taskID = 1; FileReader fileReader; BufferedReader bufferedReader = null; startTime = System.nanoTime(); try { fileReader = new FileReader(fileName); bufferedReader = new BufferedReader(fileReader); String eachTaskLine = null; mySubmittedTasks = new ConcurrentHashMap<Integer, String>(); while ((eachTaskLine = bufferedReader.readLine()) != null) { sqs.sendMessage(new SendMessageRequest(myRequestQueueUrl, taskID + " " + eachTaskLine)); mySubmittedTasks.put(taskID, eachTaskLine); taskID++; } bufferedReader.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Sent all the messages to " + requestQueueName); try { ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(myResponseQueueUrl); receiveMessageRequest.setVisibilityTimeout(900); receiveMessageRequest.setWaitTimeSeconds(20); while (!mySubmittedTasks.isEmpty()) { List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages(); for (Message message : messages) { if (mySubmittedTasks.containsKey(Integer.parseInt(message.getBody().toString()))) { mySubmittedTasks.remove(Integer.parseInt(message.getBody().toString())); String messageReceiptHandle = message.getReceiptHandle(); sqs.deleteMessage(new DeleteMessageRequest(myResponseQueueUrl, messageReceiptHandle)); } } } } catch (Exception ex) { ex.printStackTrace(); } if (!mySubmittedTasks.isEmpty()) { System.out.println("Some tasks have failed"); } endTime = System.nanoTime(); totalTime = (endTime - startTime) / 1000000000.0; System.out.println("This is " + clientOrWorker.toUpperCase() + " running with workers."); System.out.println("Total time taken: " + totalTime); System.out.println("Received all the messages from MyResponseQueue.\n"); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon SQS, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with SQS, such as not " + "being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }
From source file:pa3.RemoteWorkerSQS.java
License:Open Source License
public static void main(String[] args) throws Exception { initSQSandDynamoDB();//from w ww.j a v a 2 s. c om try { String tableName = "PA3" + args[2]; // Create table if it does not exist yet if (Tables.doesTableExist(dynamoDB, tableName)) { System.out.println("Table " + tableName + " is already ACTIVE"); } else { // Create a table with a primary hash key named 'name', which // holds a string CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName) .withKeySchema(new KeySchemaElement().withAttributeName("taskID").withKeyType(KeyType.HASH)) .withAttributeDefinitions(new AttributeDefinition().withAttributeName("taskID") .withAttributeType(ScalarAttributeType.S)) .withProvisionedThroughput( new ProvisionedThroughput().withReadCapacityUnits(1L).withWriteCapacityUnits(1L)); TableDescription createdTableDescription = dynamoDB.createTable(createTableRequest) .getTableDescription(); System.out.println("Created Table: " + createdTableDescription); // Wait for it to become active System.out.println("Waiting for " + tableName + " to become ACTIVE..."); Tables.awaitTableToBecomeActive(dynamoDB, tableName); } String noOfWorkers = args[4]; String requestQueueName = "TaskQueue" + args[2]; String responseQueueName = "TaskResponseQueue" + args[2]; String clientOrWorker = args[0]; // Create a queue //System.out.println("Accessing SQS queue: "+requestQueueName); String myRequestQueueUrl = sqs.createQueue(requestQueueName).getQueueUrl(); //System.out.println("Creating a new SQS queue called MyResponseQueue.\n"); String myResponseQueueUrl = sqs.createQueue(responseQueueName).getQueueUrl(); // Receive the messages try { ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(myRequestQueueUrl); receiveMessageRequest.setVisibilityTimeout(900); receiveMessageRequest.setWaitTimeSeconds(20); while (true) { List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages(); // Throw exception when queue gets empty if (messages.isEmpty()) { break; } for (Message message : messages) { try { String[] splitTask = message.getBody().split(" "); //DynamoDB Map<String, AttributeValue> item = newItem(splitTask[0]); PutItemRequest putItemRequest = new PutItemRequest(tableName, item) .withConditionExpression("attribute_not_exists(taskID)"); dynamoDB.putItem(putItemRequest); //System.out.println(splitTask[0]+" : "+splitTask[2]); // Execute Task Thread.sleep(Long.parseLong(splitTask[2])); sqs.sendMessage(new SendMessageRequest(myResponseQueueUrl, splitTask[0])); // Delete the message String messageReceiptHandle = message.getReceiptHandle(); sqs.deleteMessage(new DeleteMessageRequest(myRequestQueueUrl, messageReceiptHandle)); } catch (ConditionalCheckFailedException e) { //e.printStackTrace(); } } } } catch (Exception ex) { //ex.printStackTrace(); } } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to AWS, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with AWS, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } }