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



1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
# File 'lib/amazon/aws.rb', line 1319

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.
	#
	unless Amazon::AWS::Error.const_defined?( err_class )
	  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