Class RightAws::AwsError
In: lib/awsbase/right_awsbase.rb
Parent: RuntimeError
RuntimeError AwsError AwsNoChange RightAWSParser RightErrorResponseParser RightHttp2xxParser AcfInterface SqsInterface SqsGen2Interface S3Interface Ec2 SdbInterface RightAwsBase ActiveSdbConnect ActiveSdb SqsGen2 S3 S3Generator Sqs RightDummyParser AWSErrorHandler AwsBenchmarkingBlock AwsUtils RightSaxParserCallback lib/sqs/right_sqs_interface.rb lib/sqs/right_sqs_gen2.rb lib/s3/right_s3.rb lib/acf/right_acf_interface.rb lib/sqs/right_sqs_gen2_interface.rb lib/sqs/right_sqs.rb lib/sdb/right_sdb_interface.rb lib/sdb/active_sdb.rb lib/ec2/right_ec2.rb lib/s3/right_s3_interface.rb lib/awsbase/right_awsbase.rb RightAwsBaseInterface VERSION RightAws dot/m_13_0.png

Exception class to signal any Amazon errors. All errors occuring during calls to Amazon‘s web services raise this type of error. Attribute inherited by RuntimeError:

 message    - the text of the error, generally as returned by AWS in its XML response.

Methods

Attributes

errors  [R]  either an array of errors where each item is itself an array of [code, message]), or an error string if the error was raised manually, as in AwsError.new(‘err_text’)
http_code  [R]  Response HTTP error code
request_id  [R]  Request id (if exists)

Public Class methods

[Source]

     # File lib/awsbase/right_awsbase.rb, line 407
407:     def initialize(errors=nil, http_code=nil, request_id=nil)
408:       @errors      = errors
409:       @request_id  = request_id
410:       @http_code   = http_code
411:       super(@errors.is_a?(Array) ? @errors.map{|code, msg| "#{code}: #{msg}"}.join("; ") : @errors.to_s)
412:     end

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

[Source]

     # File lib/awsbase/right_awsbase.rb, line 431
431:     def self.on_aws_exception(aws, options={:raise=>true, :log=>true})
432:             # Only log & notify if not user error
433:       if !options[:raise] || system_error?($!)
434:         error_text = "#{$!.inspect}\n#{$@}.join('\n')}"
435:         puts error_text if options[:puts]
436:           # Log the error
437:         if options[:log]
438:           request  = aws.last_request  ? aws.last_request.path :  '-none-'
439:           response = aws.last_response ? "#{aws.last_response.code} -- #{aws.last_response.message} -- #{aws.last_response.body}" : '-none-'
440:           aws.logger.error error_text
441:           aws.logger.error "Request was:  #{request}"
442:           aws.logger.error "Response was: #{response}"
443:         end
444:       end
445:       raise if options[:raise]  # re-raise an exception
446:       return nil
447:     end

True if e is an AWS system error, i.e. something that is for sure not the caller‘s fault. Used to force logging.

[Source]

     # File lib/awsbase/right_awsbase.rb, line 451
451:     def self.system_error?(e)
452:             !e.is_a?(self) || e.message =~ /InternalError|InsufficientInstanceCapacity|Unavailable/
453:     end

Public Instance methods

Does any of the error messages include the regexp pattern? Used to determine whether to retry request.

[Source]

     # File lib/awsbase/right_awsbase.rb, line 416
416:     def include?(pattern)
417:       if @errors.is_a?(Array)
418:         @errors.each{ |code, msg| return true if code =~ pattern } 
419:       else
420:         return true if @errors_str =~ pattern 
421:       end
422:       false
423:     end

[Validate]