At Amazon Web Services (AWS), we’re focused on finding ways to improve our products and provide a better customer experience. To do that, we need your feedback. Please take 5 minutes of your time to share insights regarding your experience with Java Spring and your need for Spring integration with AWS.
Click here to take a quick survey
This survey is hosted by an external company (Qualtrics), so the link above does not
lead to our
website. Please note that AWS will own the data gathered via this survey, and will
not share the
information/results collected with survey respondents. AWS handles your information
as described
in the AWS Privacy Notice
Exception handling
Understanding how and when the AWS SDK for Java throws exceptions is important to building high-quality applications using the SDK. The following sections describe the different cases of exceptions that are thrown by the SDK and how to handle them appropriately.
Why unchecked exceptions?
The AWS SDK for Java uses runtime (or unchecked) exceptions instead of checked exceptions for these reasons:
-
To allow developers fine-grained control over the errors they want to handle without forcing them to handle exceptional cases they aren’t concerned about (and making their code overly verbose)
-
To prevent scalability issues inherent with checked exceptions in large applications
In general, checked exceptions work well on small scales, but can become troublesome as applications grow and become more complex.
SdkServiceException (and subclasses)
SdkServiceExceptionSdkServiceException
that’s thrown.
For some cases, a subclass of SdkServiceException
is thrown to allow developers
fine-grained control over handling error cases through catch blocks.
When you encounter an SdkServiceException
, you know that your request was successfully
sent to the AWS service but couldn’t be successfully processed. This can be because
of errors in
the request’s parameters or because of issues on the service side.
SdkServiceException
provides you with information such as:
-
Returned HTTP status code
-
Returned AWS error code
-
Detailed error message from the service
-
AWS request ID for the failed request
SdkClientException
SdkClientExceptionSdkClientException
is generally more severe than an
SdkServiceException
, and indicates a major problem that is preventing the
client from making service calls to AWS services. For example, the AWS SDK for Java
throws an SdkClientException
if no network connection is available when you try to
call an operation on one of the clients.