Exception: Common::Exceptions::BackendServiceException
- Inherits:
-
BaseError
- Object
- StandardError
- BaseError
- Common::Exceptions::BackendServiceException
- Defined in:
- lib/common/exceptions/backend_service_exception.rb
Overview
This will return a generic error, to customize you must define the minor code in the locales file and call this class from raise_error middleware.
Direct Known Subclasses
BGS::ServiceException, CentralMail::SubmitForm4142Job::CentralMailResponseError, Chip::ServiceException, DecisionReview::ServiceException, DecisionReviewV1::ServiceException, EVSS::ErrorMiddleware::EVSSBackendServiceError, MDOT::Exceptions::ServiceException
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#original_body ⇒ Object
readonly
Returns the value of attribute original_body.
-
#original_status ⇒ Object
readonly
Returns the value of attribute original_status.
-
#response_values ⇒ Object
readonly
Returns the value of attribute response_values.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(key = nil, response_values = {}, original_status = nil, original_body = nil) ⇒ BackendServiceException
constructor
rubocop:disable Metrics/ParameterLists.
-
#message ⇒ Object
The message will be the actual backend service response from middleware, not the I18n version.
-
#va900? ⇒ Boolean
(also: #generic_error?)
VA900 is characterized as a generic type of exception.
- #va900_hint ⇒ Object
- #va900_warning ⇒ Object
Methods inherited from BaseError
#log_to_sentry?, #sentry_type, #status_code
Constructor Details
#initialize(key = nil, response_values = {}, original_status = nil, original_body = nil) ⇒ BackendServiceException
rubocop:disable Metrics/ParameterLists
15 16 17 18 19 20 21 |
# File 'lib/common/exceptions/backend_service_exception.rb', line 15 def initialize(key = nil, response_values = {}, original_status = nil, original_body = nil) @response_values = response_values @key = key || 'VA900' @original_status = original_status @original_body = original_body validate_arguments! end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
12 13 14 |
# File 'lib/common/exceptions/backend_service_exception.rb', line 12 def key @key end |
#original_body ⇒ Object (readonly)
Returns the value of attribute original_body.
12 13 14 |
# File 'lib/common/exceptions/backend_service_exception.rb', line 12 def original_body @original_body end |
#original_status ⇒ Object (readonly)
Returns the value of attribute original_status.
12 13 14 |
# File 'lib/common/exceptions/backend_service_exception.rb', line 12 def original_status @original_status end |
#response_values ⇒ Object (readonly)
Returns the value of attribute response_values.
12 13 14 |
# File 'lib/common/exceptions/backend_service_exception.rb', line 12 def response_values @response_values end |
Instance Method Details
#errors ⇒ Object
30 31 32 |
# File 'lib/common/exceptions/backend_service_exception.rb', line 30 def errors Array(SerializableError.new(i18n_data.merge(render_overides))) end |
#message ⇒ Object
The message will be the actual backend service response from middleware, not the I18n version.
26 27 28 |
# File 'lib/common/exceptions/backend_service_exception.rb', line 26 def "BackendServiceException: #{response_values.merge(code:)}" end |
#va900? ⇒ Boolean Also known as: generic_error?
VA900 is characterized as a generic type of exception. See exceptions.en.yml for what JSON will render
35 36 37 |
# File 'lib/common/exceptions/backend_service_exception.rb', line 35 def va900? code == 'VA900' end |
#va900_hint ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/common/exceptions/backend_service_exception.rb', line 45 def va900_hint <<-MESSAGE.strip_heredoc Add the following to exceptions.en.yml #{response_values[:code]}: code: '#{response_values[:code]}' detail: '#{response_values[:detail]}' status: <http status code you want rendered (400, 422, etc)> source: ~ MESSAGE end |
#va900_warning ⇒ Object
41 42 43 |
# File 'lib/common/exceptions/backend_service_exception.rb', line 41 def va900_warning "Unmapped VA900 (Backend Response: { status: #{original_status}, message: #{original_body}) }" end |