class HyperResource::ResponseError

Attributes

body[RW]

The deserialized response body which led to this exception. May be blank, e.g. in case of deserialization errors.

response[RW]

The HTTPClient::Message object which led to this exception.

Public Class Methods

new(message, attrs={}) click to toggle source
Calls superclass method HyperResource::Exception::new
# File lib/hyper_resource/exceptions.rb, line 20
def initialize(message, attrs={}) # @private
  self.response = attrs[:response]
  self.body = attrs[:body]

  ## Try to help out with the message
  if body
    if (error = body['error'])
      message = "#{message} (#{error})"
    end
    if (error_message = body['message'])
      message = "#{message} (#{error_message})"
    end
  elsif response
    message = "#{message} (#{response.body})"
  end

  super(message, attrs)
end