Exception: EVSS::ServiceException
- Inherits:
-
Common::Exceptions::BaseError
- Object
- StandardError
- Common::Exceptions::BaseError
- EVSS::ServiceException
- Defined in:
- lib/evss/service_exception.rb
Direct Known Subclasses
DisabilityCompensationForm::ServiceException, IntentToFile::ServiceException, Letters::ServiceException, LoggedServiceException
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
- #error_key ⇒ Object private
-
#initialize(original_body) ⇒ ServiceException
constructor
A new instance of ServiceException.
- #messages_has_key?(key) ⇒ Boolean private
Methods inherited from Common::Exceptions::BaseError
#errors, #i18n_data, #i18n_field, #i18n_interpolated, #i18n_key, #log_to_sentry?, #message, #sentry_type, #status_code
Constructor Details
#initialize(original_body) ⇒ ServiceException
Returns a new instance of ServiceException.
9 10 11 12 13 |
# File 'lib/evss/service_exception.rb', line 9 def initialize(original_body) @messages = original_body['messages'] @key = error_key || 'evss.unmapped_service_exception' super end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/evss/service_exception.rb', line 7 def key @key end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
7 8 9 |
# File 'lib/evss/service_exception.rb', line 7 def @messages end |
Instance Method Details
#error_key ⇒ Object (private)
17 18 19 20 21 22 23 24 25 |
# File 'lib/evss/service_exception.rb', line 17 def error_key # in case of multiple errors, the ordering of ERROR_MAP is used to decide which error is highest priority. # NOTE: The ordering of ERROR_MAP takes precedence over both 1) how the error messages were ordered in the # EVSS response and 2) the "severity" keys of those messages. error_map = self.class::ERROR_MAP.select { |k, _v| (k) } return error_map.values.first unless error_map.empty? self.class::ERROR_MAP[:default] end |
#messages_has_key?(key) ⇒ Boolean (private)
27 28 29 |
# File 'lib/evss/service_exception.rb', line 27 def (key) @messages.any? { |m| m['key'].include? key.to_s } end |