Class: Tennpipes::ShowExceptions
- Inherits:
-
Sinatra::ShowExceptions
- Object
- Sinatra::ShowExceptions
- Tennpipes::ShowExceptions
- Defined in:
- lib/tennpipes-base/application/show_exceptions.rb
Overview
This module extend Sinatra::ShowExceptions adding Tennpipes as "Framework".
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tennpipes-base/application/show_exceptions.rb', line 8 def call(env) @app.call(env) rescue Exception => e errors, env["rack.errors"] = env["rack.errors"], @@eats_errors if prefers_plain_text?(env) content_type = "text/plain" exception_string = dump_exception(e) else content_type = "text/html" exception_string = pretty(env, e) end env["rack.errors"] = errors # Post 893a2c50 in rack/rack, the #pretty method above, implemented in # Rack::ShowExceptions, returns a String instead of an array. body = Array(exception_string) [ 500, {"Content-Type" => content_type, "Content-Length" => Rack::Utils.bytesize(body.join).to_s}, body ] end |