Exception: JSONAPI::Exceptions::InternalServerError

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

Instance Attribute Summary collapse

Attributes inherited from Error

#error_object_overrides

Instance Method Summary collapse

Methods inherited from Error

#create_error_object

Constructor Details

#initialize(exception, error_object_overrides = {}) ⇒ InternalServerError

Returns a new instance of InternalServerError.



24
25
26
27
# File 'lib/jsonapi/exceptions.rb', line 24

def initialize(exception, error_object_overrides = {})
  @exception = exception
  super(error_object_overrides)
end

Instance Attribute Details

#exceptionObject

Returns the value of attribute exception.



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

def exception
  @exception
end

Instance Method Details

#errorsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jsonapi/exceptions.rb', line 29

def errors
  if JSONAPI.configuration.include_backtraces_in_errors
    meta = Hash.new
    meta[:exception] = exception.message
    meta[:backtrace] = exception.backtrace
  end

  [create_error_object(code: JSONAPI::INTERNAL_SERVER_ERROR,
                       status: :internal_server_error,
                       title: I18n.t('jsonapi-resources.exceptions.internal_server_error.title',
                                     default: 'Internal Server Error'),
                       detail: I18n.t('jsonapi-resources.exceptions.internal_server_error.detail',
                                      default: 'Internal Server Error'),
                       meta: meta)]
end