Exception: SP::JSONAPI::Exceptions::GenericModelError
- Inherits:
-
StandardError
- Object
- StandardError
- SP::JSONAPI::Exceptions::GenericModelError
- Defined in:
- lib/sp/jsonapi/exceptions.rb
Overview
JSONAPI model querying errors
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(result, nested = $!) ⇒ GenericModelError
constructor
A new instance of GenericModelError.
- #inspect ⇒ Object
- #internal_error ⇒ Object
Constructor Details
#initialize(result, nested = $!) ⇒ GenericModelError
Returns a new instance of GenericModelError.
23 24 25 26 27 28 29 |
# File 'lib/sp/jsonapi/exceptions.rb', line 23 def initialize(result, nested = $!) @result = result errors = get_result_errors() @status = (errors.map { |error| error[:status].to_i }.max) || 403 = errors.first[:detail] super(, nested) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
19 20 21 |
# File 'lib/sp/jsonapi/exceptions.rb', line 19 def id @id end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
21 22 23 |
# File 'lib/sp/jsonapi/exceptions.rb', line 21 def result @result end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
20 21 22 |
# File 'lib/sp/jsonapi/exceptions.rb', line 20 def status @status end |
Instance Method Details
#inspect ⇒ Object
40 41 42 43 44 |
# File 'lib/sp/jsonapi/exceptions.rb', line 40 def inspect() description = super() description = description + " (#{internal_error})" if internal_error description end |
#internal_error ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/sp/jsonapi/exceptions.rb', line 31 def internal_error errors = get_result_errors() if errors.length != 1 @result.to_json else errors.first[:meta]['internal-error'] if errors.first[:meta] end end |