do not dump 404 traces

This commit is contained in:
Konstantin Haase 2011-06-10 13:21:52 +02:00
parent d8fc41c822
commit fd74972da1
2 changed files with 25 additions and 2 deletions

View File

@ -787,9 +787,9 @@ module Sinatra
# Error handling during requests.
def handle_exception!(boom)
@env['sinatra.error'] = boom
dump_errors!(boom) if settings.dump_errors?
status boom.respond_to?(:code) ? Integer(boom.code) : 500
dump_errors! boom if settings.dump_errors? and server_error?
raise boom if settings.show_exceptions? and settings.show_exceptions != :after_handler
@response.status = boom.respond_to?(:code) ? Integer(boom.code) : 500
if not_found?
headers['X-Cascade'] = 'pass'

View File

@ -306,6 +306,29 @@ class SettingsTest < Test::Unit::TestCase
get '/'
assert body.include?("RuntimeError") && body.include?("settings_test.rb")
end
it 'does not dump 404 errors' do
klass = Sinatra.new(Sinatra::Application)
mock_app(klass) {
enable :dump_errors
disable :raise_errors
error do
error = @env['rack.errors'].instance_variable_get(:@error)
error.rewind
error.read
end
get '/' do
raise Sinatra::NotFound
end
}
get '/'
assert !body.include?("NotFound") && !body.include?("settings_test.rb")
end
end
describe 'sessions' do