Class: Agilibox::ErrorsMiddleware

Inherits:
Object
  • Object
show all
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

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