Database Reference
In-Depth Information
Catching error information
This is as important as handling the error. When it comes to Java, you should always write
the request in try or catch blocks. In a try block, you can invoke the request, and in a
catch block, you can catch AmazonServiceException first and then AmazonCli-
entException . You can perform the process of catching an error using the following
code:
try{
// Scan items for all values
ScanRequest scanRequest = new ScanRequest("Employee");
ScanResult scanResult =
dynamoDBClient.scan(scanRequest);
}
catch(AmazonServiceException ase){
System.err.println("Failed scan table: " + "Employee");
// Get detail error information
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 e) {
System.out.println("Amazon Client Exception
:"+e.getMessage());
}
As I said earlier, it is very important to make a note of the request ID if you need to go
back to Amazon support to perform more digging into the error.
Search WWH ::




Custom Search