Method: RightAws::AwsError.on_aws_exception
- Defined in:
- lib/awsbase/right_awsbase.rb
.on_aws_exception(aws, options = {:raise=>true, :log=>true}) ⇒ Object
Generic handler for AwsErrors. aws
is the RightAws::S3, RightAws::EC2, or RightAws::SQS object that caused the exception (it must provide last_request and last_response). Supported boolean options are:
-
:log
print a message into the log using aws.logger to access the Logger -
:puts
do a “puts” of the error -
:raise
re-raise the error after logging
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/awsbase/right_awsbase.rb', line 556 def self.on_aws_exception(aws, ={:raise=>true, :log=>true}) # Only log & notify if not user error if ![:raise] || system_error?($!) error_text = "#{$!.inspect}\n#{$@}.join('\n')}" puts error_text if [:puts] # Log the error if [:log] request = aws.last_request ? aws.last_request.path : '-none-' response = aws.last_response ? "#{aws.last_response.code} -- #{aws.last_response.} -- #{aws.last_response.body}" : '-none-' aws.logger.error error_text aws.logger.error "Request was: #{request}" aws.logger.error "Response was: #{response}" end end raise if [:raise] # re-raise an exception return nil end |