mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Merge pull request #907 from kgrz/fix-error-with-rack-master
Update ShowExceptions to suit latest rack master
This commit is contained in:
commit
a43ba2c65a
1 changed files with 10 additions and 4 deletions
|
@ -24,18 +24,24 @@ module Sinatra
|
||||||
|
|
||||||
if prefers_plain_text?(env)
|
if prefers_plain_text?(env)
|
||||||
content_type = "text/plain"
|
content_type = "text/plain"
|
||||||
body = [dump_exception(e)]
|
exception_string = dump_exception(e)
|
||||||
else
|
else
|
||||||
content_type = "text/html"
|
content_type = "text/html"
|
||||||
body = pretty(env, e)
|
exception_string = pretty(env, e)
|
||||||
end
|
end
|
||||||
|
|
||||||
env["rack.errors"] = errors
|
env["rack.errors"] = errors
|
||||||
|
|
||||||
[500,
|
# 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-Type" => content_type,
|
||||||
"Content-Length" => Rack::Utils.bytesize(body.join).to_s},
|
"Content-Length" => Rack::Utils.bytesize(body.join).to_s},
|
||||||
body]
|
body
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Add table
Reference in a new issue