lib/sinatra/show_exceptions.rb in sinatra-1.4.5 vs lib/sinatra/show_exceptions.rb in sinatra-1.4.6
- old
+ new
@@ -22,21 +22,27 @@
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)]
+ exception_string = dump_exception(e)
else
content_type = "text/html"
- body = pretty(env, e)
+ exception_string = pretty(env, e)
end
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-Length" => Rack::Utils.bytesize(body.join).to_s},
- body]
+ body
+ ]
end
private
def prefers_plain_text?(env)