Exception: Lessonly::ResponseError

Inherits:
Exception
  • Object
show all
Defined in:
lib/lessonly/exceptions.rb

Direct Known Subclasses

ResourceNotFoundError

Instance Attribute Summary collapse

Attributes inherited from Exception

#cause

Instance Method Summary collapse

Constructor Details

#initialize(message, attrs = {}) ⇒ ResponseError

Returns a new instance of ResponseError.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lessonly/exceptions.rb', line 15

def initialize(message, attrs = {})
  self.response = attrs[:response]
  self.body = attrs[:body]

  if body.present? && body.key?(:error)
    error = body[:error]
    message = "#{message} (#{error})"
  elsif response
    message = "#{message} (\"#{response.inspect}\")"
  end

  super(message, attrs)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



13
14
15
# File 'lib/lessonly/exceptions.rb', line 13

def body
  @body
end

#responseObject

Returns the value of attribute response.



12
13
14
# File 'lib/lessonly/exceptions.rb', line 12

def response
  @response
end