class AWS::S3::Error

Anything you do that makes a request to S3 could result in an error. If it does, the AWS::S3 library will raise an exception specific to the error. All exception that are raised as a result of a request returning an error response inherit from the ResponseError exception. So should you choose to rescue any such exception, you can simple rescue ResponseError.

Say you go to delete a bucket, but the bucket turns out to not be empty. This results in a BucketNotEmpty error (one of the many errors listed at docs.amazonwebservices.com/AmazonS3/2006-03-01/ErrorCodeList.html):

begin
  Bucket.delete('jukebox')
rescue ResponseError => error
  # ...
end

Once you've captured the exception, you can extract the error message from S3, as well as the full error response, which includes things like the HTTP response code:

error
# => #<AWS::S3::BucketNotEmpty The bucket you tried to delete is not empty>
error.message
# => "The bucket you tried to delete is not empty"
error.response.code
# => 409

You could use this information to redisplay the error in a way you see fit, or just to log the error and continue on.