Skip to content

Commit

Permalink
Merge pull request sinatra#999 from lucasdavila/show-exceptions-refac…
Browse files Browse the repository at this point in the history
…toring

Some refactoring on ShowExceptions class.
  • Loading branch information
kytrinyx committed Apr 15, 2015
2 parents 0637611 + fbdb319 commit 0a0957a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/sinatra/show_exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,25 @@ def call(env)

if prefers_plain_text?(env)
content_type = "text/plain"
exception_string = dump_exception(e)
exception = dump_exception(e)
else
content_type = "text/html"
exception_string = pretty(env, e)
exception = pretty(env, e)
end

env["rack.errors"] = errors

# Post 893a2c50 in rack/rack, the #pretty method above, implemented in
# Rack::ShowExceptions, returns a String instead of an array.
body = Array(exception_string)
body = Array(exception)

[
500,
{"Content-Type" => content_type,
"Content-Length" => Rack::Utils.bytesize(body.join).to_s},
body
{
"Content-Type" => content_type,
"Content-Length" => Rack::Utils.bytesize(body.join).to_s
},
body
]
end

Expand Down

0 comments on commit 0a0957a

Please sign in to comment.