Exception: Served::Serializers::JsonApi::Errors
- Inherits:
-
Error
- Object
- StandardError
- Resource::Base::ServiceError
- Error
- Served::Serializers::JsonApi::Errors
- Includes:
- Enumerable
- Defined in:
- lib/served/serializers/json_api/errors.rb
Overview
Wraps all error objects
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(response) ⇒ Errors
constructor
A new instance of Errors.
Constructor Details
#initialize(response) ⇒ Errors
Returns a new instance of Errors.
11 12 13 14 15 16 17 |
# File 'lib/served/serializers/json_api/errors.rb', line 11 def initialize(response) errors_hash = JSON.parse(response.body) @errors = errors_hash['errors'].map { |error| Error.new(error) } rescue JSON::ParserError @errors = [Error.new(status: response.code, title: 'Parsing Error', detail: 'Service responded with an unparsable body')] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/served/serializers/json_api/errors.rb', line 9 def errors @errors end |
Instance Method Details
#each(&block) ⇒ Object
19 20 21 |
# File 'lib/served/serializers/json_api/errors.rb', line 19 def each(&block) errors.each(&block) end |