37signals/pow — Issue #268: Pow can't display error pages where the code snippet has a non-US-ASCII character
Author: gareth
Created: 2012-03-08 17:09:34+00:00
State: open

Pow can't display backtrace information if any code snippet in the backtrace is outside of the US-ASCII range.

# encoding: utf-8
require 'sinatra'

class TestApp < Sinatra::Base
get '/' do
raise "foo"
"¢"
end
end

Rather than a backtrace pointing to the `raise` line, the error displayed is:

Error starting application
Your Rack app raised an exception when Pow tried to run it.
ArgumentError: invalid byte sequence in US-ASCII
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/rack-1.4.1/lib/rack/utils.rb:182:in `gsub'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/rack-1.4.1/lib/rack/utils.rb:182:in `escape_html'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/rack-1.4.1/lib/rack/showexceptions.rb:94:in `h'
(erb):184:in `block (2 levels) in pretty'
(erb):183:in `each'
(erb):183:in `block in pretty'
(erb):155:in `each'
(erb):155:in `pretty'
~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/erb.rb:753:in `eval'
~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/erb.rb:753:in `result'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/rack-1.4.1/lib/rack/showexceptions.rb:88:in `pretty'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/sinatra-1.3.2/lib/sinatra/showexceptions.rb:30:in `rescue in call'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/sinatra-1.3.2/lib/sinatra/showexceptions.rb:21:in `call'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in `block in call'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/sinatra-1.3.2/lib/sinatra/base.rb:1416:in `synchronize'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in `call'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:146:in `handle'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:99:in `rescue in block (2 levels) in start'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:96:in `block (2 levels) in start'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:86:in `each'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:86:in `block in start'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:66:in `loop'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:66:in `start'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:13:in `run'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/bin/nack_worker:4:in `

'

I've created [a minimal test case](https://gist.github.com/2002019) as a gist demonstrating this behaviour.