Class: Fog::Rackspace::Errors::ServiceError
- Inherits:
-
Errors::Error
- Object
- Errors::Error
- Fog::Rackspace::Errors::ServiceError
- Defined in:
- lib/fog/rackspace/errors.rb
Direct Known Subclasses
Compute::Rackspace::ServiceError, Compute::RackspaceV2::ServiceError, DNS::Rackspace::ServiceError, AutoScale::ServiceError, BlockStorage::ServiceError, CDNV2::ServiceError, Databases::ServiceError, BadRequest, Conflict, InternalServerError, MethodNotAllowed, ServiceUnavailable, LoadBalancers::ServiceError, Monitoring::ServiceError, Networking::ServiceError, NetworkingV2::ServiceError, Orchestration::ServiceError, Queues::ServiceError, Storage::Rackspace::ServiceError
Instance Attribute Summary collapse
-
#response_data ⇒ Object
readonly
Returns the value of attribute response_data.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#response_data ⇒ Object (readonly)
Returns the value of attribute response_data.
33 34 35 |
# File 'lib/fog/rackspace/errors.rb', line 33 def response_data @response_data end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
33 34 35 |
# File 'lib/fog/rackspace/errors.rb', line 33 def status_code @status_code end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
33 34 35 |
# File 'lib/fog/rackspace/errors.rb', line 33 def transaction_id @transaction_id end |
Class Method Details
.extract_message(data) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/fog/rackspace/errors.rb', line 71 def self.(data) if data.is_a?(Hash) = data.values.first['message'] if data.values.first.is_a?(Hash) ||= data['message'] end || data.inspect end |
.slurp(error, service = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fog/rackspace/errors.rb', line 40 def self.slurp(error, service=nil) data = nil = nil status_code = nil if error.response status_code = error.response.status unless error.response.body.empty? begin data = Fog::JSON.decode(error.response.body) = (data) rescue => e Fog::Logger.warning("Received exception '#{e}' while decoding>> #{error.response.body}") = error.response.body data = error.response.body end end end new_error = super(error, ) new_error.instance_variable_set(:@response_data, data) new_error.instance_variable_set(:@status_code, status_code) new_error.set_transaction_id(error, service) new_error end |
Instance Method Details
#set_transaction_id(error, service) ⇒ Object
66 67 68 69 |
# File 'lib/fog/rackspace/errors.rb', line 66 def set_transaction_id(error, service) return unless service && service.respond_to?(:request_id_header) && error.response @transaction_id = error.response.headers[service.request_id_header] end |
#to_s ⇒ Object
35 36 37 38 |
# File 'lib/fog/rackspace/errors.rb', line 35 def to_s status = status_code ? "HTTP #{status_code}" : "HTTP <Unknown>" "[#{status} | #{transaction_id}] #{super}" end |