Exception: JSONAPI::Consumer::Errors::ResponseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/jsonapi/consumer/errors.rb

Overview

Base subclass for all response errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, response = nil) ⇒ ResponseError

Returns a new instance of ResponseError.



44
45
46
47
# File 'lib/jsonapi/consumer/errors.rb', line 44

def initialize(message=nil, response=nil)
  super(message)
  self.response = response
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



42
43
44
# File 'lib/jsonapi/consumer/errors.rb', line 42

def response
  @response
end

Instance Method Details

#errorsObject



49
50
51
# File 'lib/jsonapi/consumer/errors.rb', line 49

def errors
  response[:body].fetch('errors', [])
end

#response_bodyObject



53
54
55
# File 'lib/jsonapi/consumer/errors.rb', line 53

def response_body
  response[:body]
end