Module | Amazon::AWS::Error |
In: |
lib/amazon/aws.rb
|
All dynamically generated exceptions occur within this namespace.
# File lib/amazon/aws.rb, line 1414 def Error.exception(xml) err_class = xml.elements['Code'].text.sub( /^AWS.*\./, '' ) err_msg = xml.elements['Message'].text # Dynamically define a new exception class for this class of error, # unless it already exists. # # Note that Ruby 1.9's Module.const_defined? needs a second parameter # of *false*, or it will also search AWSError's ancestors. # cd_params = [ err_class ] cd_params << false if RUBY_VERSION >= '1.9.0' unless Amazon::AWS::Error.const_defined?( *cd_params ) Amazon::AWS::Error.const_set( err_class, Class.new( AWSError ) ) end # Generate and return a new exception from the relevant class. # Amazon::AWS::Error.const_get( err_class ).new( err_msg ) end