Class: PicoApi::Handlers::Errors
- Inherits:
-
Object
- Object
- PicoApi::Handlers::Errors
- Defined in:
- lib/pico_api/handlers/errors.rb
Defined Under Namespace
Classes: ServerError
Class Method Summary collapse
Class Method Details
.call(error, response) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/pico_api/handlers/errors.rb', line 6 def self.call(error, response) exception_key = error.class.name.demodulize.to_sym status = PicoApi.configuration.errors_map[exception_key] return system_error(error, response) unless status response.status = status Entities::Errors.call(error).to_h end |
.system_error(error, response) ⇒ Object
16 17 18 19 20 |
# File 'lib/pico_api/handlers/errors.rb', line 16 def self.system_error(error, response) response.status = :internal_server_error error = ServerError.new('Something went wrong, we are investigating') Entities::Errors.call(error).to_h end |