Exception: EVSS::DisabilityCompensationForm::ServiceException

Inherits:
ServiceException show all
Includes:
SentryLogging
Defined in:
lib/evss/disability_compensation_form/service_exception.rb

Overview

Custom exception that maps EVSS 526 errors to error details defined in config/locales/exceptions.en.yml

Constant Summary collapse

ERROR_MAP =
{
  serviceError: 'evss.external_service_unavailable',
  ServiceException: 'evss.external_service_unavailable',
  notEligible: 'evss.disability_compensation_form.not_eligible',
  InProcess: 'evss.disability_compensation_form.form_in_process',
  disabled: 'evss.disability_compensation_form.disabled',
  marshalError: 'evss.disability_compensation_form.marshall_error',
  startBatchJobError: 'evss.disability_compensation_form.start_batch_job_error',
  Size: 'common.exceptions.validation_errors',
  Pattern: 'common.exceptions.validation_errors',
  NotNull: 'common.exceptions.validation_errors',
  header: 'common.exceptions.validation_errors',
  ActiveDuty13BirthDate: 'common.exceptions.validation_errors',
  DisabilityDuplicate: 'common.exceptions.validation_errors',
  TreatmentPastActiveDutyDate: 'common.exceptions.validation_errors',
  AttachmentType: 'common.exceptions.validation_errors',
  directDeposit: 'common.exceptions.validation_errors',
  disabilities: 'common.exceptions.validation_errors',
  militaryPayments: 'common.exceptions.validation_errors',
  serviceInformation: 'common.exceptions.validation_errors',
  treatments: 'common.exceptions.validation_errors',
  VeteranRecordWsClientException: 'evss.disability_compensation_form.ws_client_exception',
  veteran: 'common.exceptions.validation_errors',
  MaxEPCode: 'evss.disability_compensation_form.max_ep_code',
  PIFInUse: 'evss.disability_compensation_form.pif_in_use',
  refdataservice: 'refdataservice.errorResponse',
  default: 'evss.unmapped_service_exception'
}.freeze

Instance Attribute Summary

Attributes inherited from ServiceException

#key, #messages

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

Methods inherited from ServiceException

#error_key, #initialize, #messages_has_key?

Methods inherited from Common::Exceptions::BaseError

#i18n_data, #i18n_field, #i18n_interpolated, #log_to_sentry?, #message, #sentry_type, #status_code

Constructor Details

This class inherits a constructor from EVSS::ServiceException

Instance Method Details

#errorsObject



51
52
53
54
55
56
57
# File 'lib/evss/disability_compensation_form/service_exception.rb', line 51

def errors
  Array(
    Common::Exceptions::SerializableError.new(
      i18n_data.merge(source: 'EVSS::DisabilityCompensationForm::Service', meta: { messages: @messages })
    )
  )
end

#i18n_keyObject (private)



73
74
75
# File 'lib/evss/disability_compensation_form/service_exception.rb', line 73

def i18n_key
  @key
end

#only_has_retriable_message_texts?Boolean (private)

Returns:

  • (Boolean)


61
62
63
# File 'lib/evss/disability_compensation_form/service_exception.rb', line 61

def only_has_retriable_message_texts?
  @messages.none? { |msg| msg['text'].include?('EP Code is not valid') }
end

#refdataservice_unreachable?Boolean (private)

Returns:

  • (Boolean)


65
66
67
68
69
70
71
# File 'lib/evss/disability_compensation_form/service_exception.rb', line 65

def refdataservice_unreachable?
  texts = [
    'Reference Data Service was unable to verify',
    'Reference Data Service is unavailable to verify'
  ]
  @messages.all? { |msg| texts.include?(msg['text']) }
end

#retryable?Boolean

Retry if any upstream external service unavailability exceptions (unless it is caused by an invalid EP code) and any PIF-in-use exceptions are encountered.

Returns:

  • (Boolean)


44
45
46
47
48
49
# File 'lib/evss/disability_compensation_form/service_exception.rb', line 44

def retryable?
  (@key == 'evss.external_service_unavailable' && only_has_retriable_message_texts?) ||
    (@key == 'evss.disability_compensation_form.pif_in_use') ||
    (@key == 'evss.disability_compensation_form.ws_client_exception') ||
    (@key == 'refdataservice.errorResponse' && refdataservice_unreachable?)
end