Exception: Fog::VcloudDirector::Errors::ServiceError
- Inherits:
-
Errors::Error
- Object
- StandardError
- Errors::Error
- Fog::VcloudDirector::Errors::ServiceError
- Defined in:
- lib/fog/vcloud_director/core.rb
Direct Known Subclasses
Compute::VcloudDirector::ServiceError, BadRequest, Conflict, DuplicateName, Forbidden, TaskError, Unauthorized
Instance Attribute Summary collapse
-
#major_error_code ⇒ Object
readonly
Returns the value of attribute major_error_code.
-
#minor_error_code ⇒ Object
readonly
Returns the value of attribute minor_error_code.
-
#stack_trace ⇒ Object
readonly
Returns the value of attribute stack_trace.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
-
#vendor_specific_error_code ⇒ Object
readonly
Returns the value of attribute vendor_specific_error_code.
Attributes inherited from Errors::Error
Class Method Summary collapse
Instance Attribute Details
#major_error_code ⇒ Object (readonly)
Returns the value of attribute major_error_code.
10 11 12 |
# File 'lib/fog/vcloud_director/core.rb', line 10 def major_error_code @major_error_code end |
#minor_error_code ⇒ Object (readonly)
Returns the value of attribute minor_error_code.
9 10 11 |
# File 'lib/fog/vcloud_director/core.rb', line 9 def minor_error_code @minor_error_code end |
#stack_trace ⇒ Object (readonly)
Returns the value of attribute stack_trace.
11 12 13 |
# File 'lib/fog/vcloud_director/core.rb', line 11 def stack_trace @stack_trace end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
12 13 14 |
# File 'lib/fog/vcloud_director/core.rb', line 12 def status_code @status_code end |
#vendor_specific_error_code ⇒ Object (readonly)
Returns the value of attribute vendor_specific_error_code.
13 14 15 |
# File 'lib/fog/vcloud_director/core.rb', line 13 def vendor_specific_error_code @vendor_specific_error_code end |
Class Method Details
.slurp(error, service = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fog/vcloud_director/core.rb', line 15 def self.slurp(error, service=nil) major_error_code = nil = nil minor_error_code = nil stack_trace = nil status_code = nil vendor_specific_error_code = nil if error.response status_code = error.response.status unless error.response.body.empty? _, media_type = error.response.headers.detect {|k,v| k.downcase == 'content-type'} if media_type =~ /vnd\.vmware\.vcloud\.error\+xml/i begin document = Fog::ToHashDocument.new Nokogiri::XML::SAX::Parser.new(document).parse_memory(error.response.body) major_error_code = document.body[:majorErrorCode] = document.body[:message] minor_error_code = document.body[:minorErrorCode] stack_trace = document.body[:stackTrace] vendor_specific_error_code = document.body[:vendorSpecificErrorCode] rescue => e Fog::Logger.warning("Received exception '#{e}' while decoding>> #{error.response.body}") = error.response.body end else = CGI::unescapeHTML(error.response.body) end end end new_error = super(error, ) new_error.instance_variable_set(:@major_error_code, major_error_code) new_error.instance_variable_set(:@minor_error_code, minor_error_code) new_error.instance_variable_set(:@stack_trace, stack_trace) new_error.instance_variable_set(:@status_code, status_code) new_error.instance_variable_set(:@vendor_specific_error_code, vendor_specific_error_code) new_error end |