Method: Sinatra::ShowExceptions#call
- Defined in:
- lib/sinatra/show_exceptions.rb
#call(env) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sinatra/show_exceptions.rb', line 21 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" body = dump_exception(e) else content_type = "text/html" body = pretty(env, e) end env["rack.errors"] = errors [ 500, { "Content-Type" => content_type, "Content-Length" => body.bytesize.to_s }, [body] ] end |