Skip to content

Commit

Permalink
Fix blank error pages when error.messages has no to_str
Browse files Browse the repository at this point in the history
When an exception whose #messages attribute is not a string is
rescued, Sinatra fails to display the error page due to a
TypeError. The problem is that Ruby's + implementation uses type-strong
coercing (#to_str) instead of type-weak coercision (#to_s). This just
forces to_s to be used, avoiding the problem.

(An example of this type of exception is DataMapper::Errors. It doesn't
respond to #to_str)
  • Loading branch information
rtomayko committed May 24, 2008
1 parent f5ec72d commit 28effb3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sinatra.rb
Expand Up @@ -1313,7 +1313,7 @@ def load_default_configuration!
Params: <pre>#{params.inspect}
</div>
<div id="stacktrace">
<h1>#{Rack::Utils.escape_html(@error.class.name + ' - ' + @error.message)}</h1>
<h1>#{Rack::Utils.escape_html(@error.class.name + ' - ' + @error.message.to_s)}</h1>
<pre><code>#{Rack::Utils.escape_html(@error.backtrace.join("\n"))}</code></pre>
</div>
</body>
Expand Down

0 comments on commit 28effb3

Please sign in to comment.