Adding some S3 error handling logic.