Class: Rackables::HideExceptions
- Inherits:
-
Object
- Object
- Rackables::HideExceptions
- Defined in:
- lib/rackables/hide_exceptions.rb
Overview
Returns a user-friendly exception page Should be included at the very top of the middleware pipeline so that unhandled exceptions from anywhere down the pipeline are rescued In development, you’d want to use Rack::ShowExceptions instead of this (config.ru example):
if ENV['RACK_ENV'] == 'development'
use Rack::ShowExceptions
else
use Rackables::HideExceptions
end
The default HTML included here is a copy of the 500 page included with Rails You can optionally specify your own file, ex:
use Rackables::HideExceptions, "public/500.html"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, file_path = nil) ⇒ HideExceptions
constructor
A new instance of HideExceptions.
Constructor Details
#initialize(app, file_path = nil) ⇒ HideExceptions
Returns a new instance of HideExceptions.
18 19 20 21 |
# File 'lib/rackables/hide_exceptions.rb', line 18 def initialize(app, file_path = nil) @app = app @file_path = file_path end |
Instance Method Details
#call(env) ⇒ Object
23 24 25 26 27 |
# File 'lib/rackables/hide_exceptions.rb', line 23 def call(env) @app.call(env) rescue ::Exception [500, {'Content-Type' => 'text/html', 'Content-Length' => html.length.to_s}, [html]] end |