module Rack # Rack::ShowExceptions catches exceptions raised from the app, # showing a useful backtrace with clickable stack frames and # TextMate links to source files, as well as the last database # query, GET/POST params, cookies, and Rack environment variables. # # Be careful using this on public-facing sites as it could reveal # potentially sensitive information to malicious users. class ShowExceptions def initialize(app) @app = app end def call(env) @app.call(env) rescue StandardError, LoadError, SyntaxError => e body = Kiss::ExceptionReport.generate(env, e) [500, { "Content-Type" => "text/html", "Content-Length" => body.length.to_s, "X-Kiss-Error-Type" => e.class.name, "X-Kiss-Error-Message" => e.message.sub(/\n.*/m,'') }, body] end end end