Exception: Common::Exceptions::BaseError
- Inherits:
-
StandardError
- Object
- StandardError
- Common::Exceptions::BaseError
show all
- Defined in:
- lib/common/exceptions/base_error.rb
Overview
Base error class all others inherit from
Direct Known Subclasses
AmbiguousRequest, BackendServiceException, DetailedSchemaErrors, FailedDependency, FilterNotAllowed, Forbidden, GatewayTimeout, InternalServerError, InvalidField, InvalidFieldValue, InvalidFiltersSyntax, InvalidPaginationParams, InvalidResource, InvalidSortCriteria, MessageAuthenticityError, NoQueryParamsAllowed, OpenIdServiceError, ParameterMissing, ParametersMissing, RecordNotFound, RoutingError, SchemaValidationErrors, ServiceError, ServiceOutage, Timeout, TokenValidationError, TooManyRequests, Unauthorized, ValidationErrors, EVSS::ServiceException, Lighthouse::LettersGenerator::ServiceError, Rx::RxGatewayTimeout, VIC::IDCardAttributeError
Instance Method Summary
collapse
Instance Method Details
#errors ⇒ Object
7
8
9
|
# File 'lib/common/exceptions/base_error.rb', line 7
def errors
raise NotImplementedError, 'Subclass of Error must implement errors method'
end
|
#i18n_data ⇒ Object
38
39
40
|
# File 'lib/common/exceptions/base_error.rb', line 38
def i18n_data
I18n.t(i18n_key)
end
|
#i18n_field(attribute, options) ⇒ Object
42
43
44
45
46
|
# File 'lib/common/exceptions/base_error.rb', line 42
def i18n_field(attribute, options)
I18n.t("#{i18n_key}.#{attribute}", **options)
rescue
nil
end
|
#i18n_interpolated(options = {}) ⇒ Object
48
49
50
51
|
# File 'lib/common/exceptions/base_error.rb', line 48
def i18n_interpolated(options = {})
merge_values = options.map { |attribute, opts| [attribute, i18n_field(attribute, opts)] }.to_h
i18n_data.merge(merge_values)
end
|
#i18n_key ⇒ Object
34
35
36
|
# File 'lib/common/exceptions/base_error.rb', line 34
def i18n_key
"common.exceptions.#{self.class.name.split('::').last.underscore}"
end
|
#log_to_sentry? ⇒ Boolean
28
29
30
|
# File 'lib/common/exceptions/base_error.rb', line 28
def log_to_sentry?
sentry_type != 'none'
end
|
#message ⇒ Object
18
19
20
|
# File 'lib/common/exceptions/base_error.rb', line 18
def message
i18n_data[:title]
end
|
#sentry_type ⇒ Object
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_code ⇒ Object
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
|