Skip to content

Commit

Permalink
Merge pull request #907 from kgrz/fix-error-with-rack-master
Browse files Browse the repository at this point in the history
Update ShowExceptions to suit latest rack master
  • Loading branch information
Zachary Scott committed Aug 11, 2014
2 parents 68c237d + b39d72d commit a43ba2c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/sinatra/show_exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,24 @@ def call(env)

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
Expand Down

0 comments on commit a43ba2c

Please sign in to comment.