class SP::Duh::JSONAPI::Exceptions::GenericModelError
JSONAPI
model querying errors
Attributes
id[R]
result[R]
status[R]
Public Class Methods
new(result, nested = $!)
click to toggle source
Calls superclass method
SP::Duh::Exceptions::GenericError::new
# File lib/sp/duh/jsonapi/exceptions.rb, line 24 def initialize(result, nested = $!) @result = result errors = get_result_errors() @status = (errors.map { |error| error[:status].to_i }.max) || 403 message = errors.first[:detail] super(message, nested) end
Public Instance Methods
inspect()
click to toggle source
Calls superclass method
# File lib/sp/duh/jsonapi/exceptions.rb, line 41 def inspect() description = super() description = description + " (#{internal_error})" if internal_error description end
internal_error()
click to toggle source
# File lib/sp/duh/jsonapi/exceptions.rb, line 32 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
Private Instance Methods
get_result_errors()
click to toggle source
# File lib/sp/duh/jsonapi/exceptions.rb, line 49 def get_result_errors() ; (result.is_a?(Hash) ? result : HashWithIndifferentAccess.new(JSON.parse(result)))[:errors] ; end