Module: Amazon::AWS::Error
- Defined in:
- lib/amazon/aws.rb
Overview
All dynamically generated exceptions occur within this namespace.
Defined Under Namespace
Classes: AWSError
Class Method Summary collapse
Class Method Details
.exception(xml) ⇒ Object
1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 |
# File 'lib/amazon/aws.rb', line 1432 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 |