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.



40
41
42
43
# File 'lib/jsonapi/exceptions.rb', line 40

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

Instance Attribute Details

#exceptionObject

Returns the value of attribute exception.



38
39
40
# File 'lib/jsonapi/exceptions.rb', line 38

def exception
  @exception
end

Instance Method Details

#errorsObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/jsonapi/exceptions.rb', line 45

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

  if JSONAPI.configuration.include_application_backtraces_in_errors
    meta ||= Hash.new
    meta[:exception] ||= exception.message
    meta[:application_backtrace] = exception.backtrace.select{|line| line =~ /#{Rails.root}/}
  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