mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Bugfix. show_exceptions used to override app-specified exceptions (error do ... end blocks).
Signed-off-by: Konstantin Haase <konstantin.mailinglists@googlemail.com>
This commit is contained in:
parent
a1052fe960
commit
732bc75d57
2 changed files with 24 additions and 1 deletions
|
@ -725,7 +725,6 @@ module Sinatra
|
|||
@env['sinatra.error'] = boom
|
||||
|
||||
dump_errors!(boom) if settings.dump_errors?
|
||||
raise boom if settings.show_exceptions?
|
||||
|
||||
@response.status = 500
|
||||
if res = error_block!(boom.class)
|
||||
|
@ -750,6 +749,7 @@ module Sinatra
|
|||
end
|
||||
end
|
||||
end
|
||||
raise boom if settings.show_exceptions? and keys == Exception
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -202,6 +202,29 @@ class SettingsTest < Test::Unit::TestCase
|
|||
assert body.include?("StandardError")
|
||||
assert body.include?("<code>show_exceptions</code> setting")
|
||||
end
|
||||
|
||||
it 'does not override app-specified error handling' do
|
||||
klass = Sinatra.new(Sinatra::Application)
|
||||
mock_app(klass) {
|
||||
enable :show_exceptions
|
||||
|
||||
error RuntimeError do
|
||||
'Big mistake !'
|
||||
end
|
||||
|
||||
get '/' do
|
||||
raise RuntimeError
|
||||
end
|
||||
}
|
||||
|
||||
get '/'
|
||||
assert_equal 500, status
|
||||
|
||||
assert ! body.include?("<code>")
|
||||
assert body.include? "Big mistake !"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'dump_errors' do
|
||||
|
|
Loading…
Add table
Reference in a new issue