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.



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

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.



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

def http_body
  @http_body
end

#http_messageObject (readonly)

Returns the value of attribute http_message.



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

def http_message
  @http_message
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



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

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



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

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