Module: Amazon::AWS::Error
- Defined in:
- lib/ruby-paa/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
1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 |
# File 'lib/ruby-paa/aws.rb', line 1411 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 |