Class: Users::ExceptionHandler
- Inherits:
-
Object
- Object
- Users::ExceptionHandler
- Includes:
- Common::Client::Concerns::ServiceStatus
- Defined in:
- app/services/users/exception_handler.rb
Constant Summary
Constants included from Common::Client::Concerns::ServiceStatus
Common::Client::Concerns::ServiceStatus::RESPONSE_STATUS
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
-
#initialize(error, service) ⇒ ExceptionHandler
constructor
A new instance of ExceptionHandler.
-
#serialize_error ⇒ Hash
Serializes the initialized error into one of the predetermined error types.
Constructor Details
#initialize(error, service) ⇒ ExceptionHandler
Returns a new instance of ExceptionHandler.
16 17 18 19 |
# File 'app/services/users/exception_handler.rb', line 16 def initialize(error, service) @error = validate!(error) @service = service end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
11 12 13 |
# File 'app/services/users/exception_handler.rb', line 11 def error @error end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
11 12 13 |
# File 'app/services/users/exception_handler.rb', line 11 def service @service end |
Instance Method Details
#serialize_error ⇒ Hash
Serializes the initialized error into one of the predetermined error types. Uses error classes that can be triggered by MVI, EMIS, or Vet360.
The serialized error format is modelled after the Maintenance Windows schema, per the FE’s request.
window schema.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/services/users/exception_handler.rb', line 31 def serialize_error case error when Common::Exceptions::BaseError base_error when VAProfile::VeteranStatus::VAProfileError if error.status == 404 title_error(:not_found) else standard_va_profile_error end when Common::Client::Errors::ClientError client_error when MPI::Errors::RecordNotFound mpi_error(404) when MPI::Errors::FailedRequestError mpi_error(503) when MPI::Errors::DuplicateRecords mpi_error(404) else standard_error end end |