Exception: HyperResource::Exception

Inherits:
Exception
  • Object
show all
Defined in:
lib/hyper_resource/exceptions.rb

Direct Known Subclasses

ClientError, ResponseError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, opts = {}) ⇒ Exception

Returns a new instance of Exception.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hyper_resource/exceptions.rb', line 7

def initialize(message, opts={})
  self.response = opts[:response]
  self.response_object = opts[:response_object]
  self.cause = opts[:cause]

  ## Try to help out with the message
  if self.response_object
    if error = self.response_object['error']
      message = "#{message} (#{error})"
    end
  elsif self.response
    message = "#{message} (\"#{self.response.inspect}\")"
  end

  super(message)
end

Instance Attribute Details

#causeObject

Internal exception which led to this



5
6
7
# File 'lib/hyper_resource/exceptions.rb', line 5

def cause
  @cause
end

#responseObject

Response body which led to this



3
4
5
# File 'lib/hyper_resource/exceptions.rb', line 3

def response
  @response
end

#response_objectObject

Response object which led to this



4
5
6
# File 'lib/hyper_resource/exceptions.rb', line 4

def response_object
  @response_object
end