Exception: SP::JSONAPI::Exceptions::GenericModelError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/sp/jsonapi/exceptions.rb

Overview

JSONAPI model querying errors

Instance Attribute Summary collapse

Instance Method Summary collapse

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
  message = errors.first[:detail]
  super(message, nested)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



19
20
21
# File 'lib/sp/jsonapi/exceptions.rb', line 19

def id
  @id
end

#resultObject (readonly)

Returns the value of attribute result.



21
22
23
# File 'lib/sp/jsonapi/exceptions.rb', line 21

def result
  @result
end

#statusObject (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

#inspectObject



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_errorObject



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