23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/rack/showexceptions.rb', line 23
def call(env)
@app.call(env)
rescue StandardError, LoadError, SyntaxError => e
exception_string = dump_exception(e)
env["rack.errors"].puts(exception_string)
env["rack.errors"].flush
if prefers_plain_text?(env)
content_type = "text/plain"
body = [exception_string]
else
content_type = "text/html"
body = pretty(env, e)
end
[500,
{"Content-Type" => content_type,
"Content-Length" => Rack::Utils.bytesize(body.join).to_s},
body]
end
|