Exception: Escobar::Client::HTTPError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/escobar/client.rb

Overview

Class for returning API errors to escobar clients

Direct Known Subclasses

Error::SecondFactor, Error::Unauthorized

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



19
20
21
# File 'lib/escobar/client.rb', line 19

def body
  @body
end

#headersObject

Returns the value of attribute headers.



19
20
21
# File 'lib/escobar/client.rb', line 19

def headers
  @headers
end

#statusObject

Returns the value of attribute status.



19
20
21
# File 'lib/escobar/client.rb', line 19

def status
  @status
end

Class Method Details

.from_error(err) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/escobar/client.rb', line 20

def self.from_error(err)
  error = new("Error from Heroku API")

  error.body    = err.response[:body]
  error.headers = err.response[:headers]
  error.status  = err.response[:status]

  error.set_backtrace(err.backtrace)
  error
end

.from_response(resp, message = "Error from Heroku API") ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/escobar/client.rb', line 41

def self.from_response(resp, message = "Error from Heroku API")
  error = new(message)

  error.body    = resp.body
  error.headers = resp.headers
  error.status  = resp.status

  error
end

.from_response_env(resp, message = "Error from Heroku API") ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/escobar/client.rb', line 31

def self.from_response_env(resp, message = "Error from Heroku API")
  error = new(message)

  error.body    = resp.body
  error.headers = resp.response_headers
  error.status  = resp.status

  error
end