Exception: Tito::Errors::ApiError

Inherits:
Error
  • Object
show all
Defined in:
lib/tito/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status: nil, body: nil) ⇒ ApiError

Returns a new instance of ApiError.



9
10
11
12
13
14
# File 'lib/tito/errors.rb', line 9

def initialize(message = nil, status: nil, body: nil)
  @status = status
  @body = body
  @errors = body.is_a?(Hash) ? (body["errors"] || {}) : {}
  super(message || (body.is_a?(Hash) && body["message"]) || "API error (#{status})")
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/tito/errors.rb', line 7

def body
  @body
end

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/tito/errors.rb', line 7

def errors
  @errors
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/tito/errors.rb', line 7

def status
  @status
end