In this section, we are going to talk about how to handle errors in DynamoDB. We have seen how to make client requests in earlier chapters of this book. There, we had not put the error-handling mechanism, which we would be doing now.
There are two types of errors in AWS:
Client errors: These normally come when the request we are submitting is incorrect. The client errors are normally shown with the status code starting with 4XX. These errors normally arrive when there is an authentication failure, bad requests, missing required attributes, or for exceeding the provisioned throughput. The errors normally come when users provide invalid inputs.
Server errors: These arrive when there is something wrong from Amazon's side, and they appear at runtime. The only way to handle such errors is to try again, and even then if it does not succeed, then you should log the request ID and reach Amazon support with that ID to know more about the details.