Exception: JSONAPI::Exceptions::InternalServerError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ InternalServerError


8
9
10
# File 'lib/jsonapi/exceptions.rb', line 8

def initialize(exception)
  @exception = exception
end

Instance Attribute Details

#exceptionObject

Returns the value of attribute exception


6
7
8
# File 'lib/jsonapi/exceptions.rb', line 6

def exception
  @exception
end

Instance Method Details

#errorsObject


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jsonapi/exceptions.rb', line 12

def errors
  unless Rails.env.production?
    meta = Hash.new
    meta[:exception] = exception.message
    meta[:backtrace] = exception.backtrace
  end

  [JSONAPI::Error.new(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