Exception: SpyriApi::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/spyri_api/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, body) ⇒ Error

Returns a new instance of Error.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/spyri_api/error.rb', line 8

def initialize(status, body)
  @status = status
  if @status == 404
    @code = 'not_found'
  else
    data = JSON.parse(body)
    @code = data['code']
    @details = data['details']
  end
  super @code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/spyri_api/error.rb', line 6

def code
  @code
end

#detailsObject (readonly)

Returns the value of attribute details.



6
7
8
# File 'lib/spyri_api/error.rb', line 6

def details
  @details
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/spyri_api/error.rb', line 6

def status
  @status
end

Instance Method Details

#inspectObject



20
21
22
# File 'lib/spyri_api/error.rb', line 20

def inspect
  "<#{self.class}: #{instance_variables.map { |v| "#{v}=#{instance_variable_get(v)}"}.join(', ')}>"
end