Class: Rack::ShowStackDeck
- Inherits:
-
Object
- Object
- Rack::ShowStackDeck
- Defined in:
- lib/rack/show_stackdeck.rb
Overview
Rack::ShowStackDeck catches all exceptions raised from the app it wraps. It shows a useful backtrace with the sourcefile and clickable context, the whole Rack environment and the request data.
Be careful when you use this on public-facing sites as it could reveal information helpful to attackers.
Rack::ShowStackDeck is based on, and functionally very similar to, Rack::ShowExceptions – the key difference is that it uses the StackDeck library to show the full cross-language backtrace, where relevant.
Constant Summary collapse
- FILTER_ENV =
[/^rack\./]
- HIDE_FIELD =
[]
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ ShowStackDeck
constructor
A new instance of ShowStackDeck.
Constructor Details
#initialize(app, options = {}) ⇒ ShowStackDeck
Returns a new instance of ShowStackDeck.
23 24 25 26 27 28 |
# File 'lib/rack/show_stackdeck.rb', line 23 def initialize(app, ={}) @app = app @template = ERB.new(TEMPLATE) @exception_status = Hash.new(500) @exception_status.update([:exception_status]) if [:exception_status] end |
Instance Method Details
#call(env) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/rack/show_stackdeck.rb', line 30 def call(env) @app.call(env) rescue StandardError, ScriptError, Timeout::Error => e data, status = pretty_data(env, e) [status, {"Content-Type" => "text/html"}, [@template.result(data)]] end |