Class: Agilibox::ErrorsMiddleware
- Inherits:
-
Object
- Object
- Agilibox::ErrorsMiddleware
- Defined in:
- lib/agilibox/errors_middleware.rb
Constant Summary collapse
- MAINTENANCE_ERRORS =
[ PG::ConnectionBad, PG::UnableToSend, ]
- NOT_ACCEPTABLE_ERRORS =
[ ActionController::UnknownFormat, ActionController::UnknownHttpMethod, ActionView::MissingTemplate, ]
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ ErrorsMiddleware
constructor
A new instance of ErrorsMiddleware.
Constructor Details
#initialize(app) ⇒ ErrorsMiddleware
13 14 15 |
# File 'lib/agilibox/errors_middleware.rb', line 13 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/agilibox/errors_middleware.rb', line 17 def call(env) @app.call(env) rescue *MAINTENANCE_ERRORS respond_with 503, "Maintenance en cours." rescue *NOT_ACCEPTABLE_ERRORS respond_with 406, "Not acceptable." end |