Exception: Frame::APIError

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

Overview

API Error class for handling API responses

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, http_status: nil, http_body: nil, json_body: nil, code: nil) ⇒ APIError

Returns a new instance of APIError.



15
16
17
18
19
20
21
22
# File 'lib/frame/error.rb', line 15

def initialize(message = nil, http_status: nil, http_body: nil, json_body: nil, code: nil)
  @message = message
  @http_status = http_status
  @http_body = http_body
  @json_body = json_body
  @code = code
  super(message)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



13
14
15
# File 'lib/frame/error.rb', line 13

def code
  @code
end

#http_bodyObject (readonly)

Returns the value of attribute http_body.



11
12
13
# File 'lib/frame/error.rb', line 11

def http_body
  @http_body
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



10
11
12
# File 'lib/frame/error.rb', line 10

def http_status
  @http_status
end

#json_bodyObject (readonly)

Returns the value of attribute json_body.



12
13
14
# File 'lib/frame/error.rb', line 12

def json_body
  @json_body
end

#messageObject (readonly)

Returns the value of attribute message.



9
10
11
# File 'lib/frame/error.rb', line 9

def message
  @message
end

Instance Method Details

#to_sObject



24
25
26
27
28
# File 'lib/frame/error.rb', line 24

def to_s
  status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
  code_string = @code.nil? ? "" : "(Code #{@code}) "
  "#{status_string}#{code_string}#{@message}"
end