Exception: Common::Exceptions::InternalServerError

Inherits:
BaseError
  • Object
show all
Defined in:
lib/common/exceptions/internal_server_error.rb

Overview

Internal Server Error - all exceptions not readily accounted fall into this tier

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseError

#log_to_sentry?, #message, #sentry_type, #status_code

Constructor Details

#initialize(exception) ⇒ InternalServerError

Returns a new instance of InternalServerError.

Raises:

  • (ArgumentError)


12
13
14
15
16
# File 'lib/common/exceptions/internal_server_error.rb', line 12

def initialize(exception)
  raise ArgumentError, 'an exception must be provided' unless exception.is_a?(Exception)

  @exception = exception
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



10
11
12
# File 'lib/common/exceptions/internal_server_error.rb', line 10

def exception
  @exception
end

Instance Method Details

#errorsObject



18
19
20
21
# File 'lib/common/exceptions/internal_server_error.rb', line 18

def errors
  meta = { exception: exception.message, backtrace: exception.backtrace } unless ::Rails.env.production?
  Array(SerializableError.new(i18n_data.merge(meta:)))
end