Class: Rack::ShowStackDeck

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

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, options={})
  @app = app
  @template = ERB.new(TEMPLATE)
  @exception_status = Hash.new(500)
  @exception_status.update(options[:exception_status]) if options[: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