Exception: FatZebra::RequestError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/fat_zebra/errors.rb

Overview

Request to API Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, message: nil) ⇒ RequestError

Returns a new instance of RequestError.



24
25
26
27
28
29
# File 'lib/fat_zebra/errors.rb', line 24

def initialize(response, message: nil)
  @http_status      = response.code.to_i
  @http_status_type = response.code_type
  @http_body        = response.body
  @http_message     = message || response.message
end

Instance Attribute Details

#http_bodyObject (readonly)

Returns the value of attribute http_body.



19
20
21
# File 'lib/fat_zebra/errors.rb', line 19

def http_body
  @http_body
end

#http_messageObject (readonly)

Returns the value of attribute http_message.



22
23
24
# File 'lib/fat_zebra/errors.rb', line 22

def http_message
  @http_message
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



20
21
22
# File 'lib/fat_zebra/errors.rb', line 20

def http_status
  @http_status
end

#http_status_typeObject (readonly)

Returns the value of attribute http_status_type.



21
22
23
# File 'lib/fat_zebra/errors.rb', line 21

def http_status_type
  @http_status_type
end

Instance Method Details

#to_sObject



31
32
33
# File 'lib/fat_zebra/errors.rb', line 31

def to_s
  "Status #{http_status}: #{http_message}"
end