Exception: Alchemrest::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/alchemrest/error.rb

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ResponseError

Returns a new instance of ResponseError.



17
18
19
20
# File 'lib/alchemrest/error.rb', line 17

def initialize(response)
  super
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



15
16
17
# File 'lib/alchemrest/error.rb', line 15

def response
  @response
end

Instance Method Details

#deconstructObject



31
32
33
# File 'lib/alchemrest/error.rb', line 31

def deconstruct
  [response.status, response.error_details]
end

#deconstruct_keys(_keys) ⇒ Object



35
36
37
# File 'lib/alchemrest/error.rb', line 35

def deconstruct_keys(_keys)
  { status: response.status, error: response.error_details }
end

#to_sObject



22
23
24
25
26
27
28
29
# File 'lib/alchemrest/error.rb', line 22

def to_s
  method = response.env.method
  url = response.env.url
  [
    "HTTP #{response.status} for #{method.upcase} #{url}",
    response.error_details.to_s,
  ].compact.join(" - ")
end