Exception: Common::Exceptions::BaseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/common/exceptions/base_error.rb

Overview

Base error class all others inherit from

Instance Method Summary collapse

Instance Method Details

#errorsObject

Raises:

  • (NotImplementedError)


7
8
9
# File 'lib/common/exceptions/base_error.rb', line 7

def errors
  raise NotImplementedError, 'Subclass of Error must implement errors method'
end

#log_to_sentry?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/common/exceptions/base_error.rb', line 28

def log_to_sentry?
  sentry_type != 'none'
end

#messageObject



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

def message
  i18n_data[:title]
end

#sentry_typeObject

This determines how the exception should get logged to Sentry in adddition to available types from Sentry: ‘warn’, ‘info’, ‘error’ there is ‘none’ to not log to Sentry at all



24
25
26
# File 'lib/common/exceptions/base_error.rb', line 24

def sentry_type
  i18n_data[:sentry_type].presence || 'error'
end

#status_codeObject



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

def status_code
  return if errors&.first.blank?
  return errors.first[:status]&.to_i if errors.first.is_a?(Hash)

  errors&.first&.status&.to_i
end