OPS-250 Modifying liquid error handling so that it no longer captures Exceptions that are not subclasses of StandardError (previously, it was rescuing things like Interrupt and NoMemoryError).

This commit is contained in:
Austin Mills
2011-01-10 14:55:05 -06:00
parent 0526348cae
commit 4fec29f288
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -92,7 +92,7 @@ module Liquid
list.collect do |token| list.collect do |token|
begin begin
token.respond_to?(:render) ? token.render(context) : token token.respond_to?(:render) ? token.render(context) : token
rescue Exception => e rescue ::StandardError => e
context.handle_error(e) context.handle_error(e)
end end
end end
+12
View File
@@ -13,6 +13,10 @@ class ErrorDrop < Liquid::Drop
raise Liquid::SyntaxError, 'syntax error' raise Liquid::SyntaxError, 'syntax error'
end end
def exception
raise Exception, 'exception'
end
end end
class ErrorHandlingTest < Test::Unit::TestCase class ErrorHandlingTest < Test::Unit::TestCase
@@ -66,4 +70,12 @@ class ErrorHandlingTest < Test::Unit::TestCase
assert_equal Liquid::ArgumentError, template.errors.first.class assert_equal Liquid::ArgumentError, template.errors.first.class
end end
end end
# Liquid should not catch Exceptions that are not subclasses of StandardError, like Interrupt and NoMemoryError
def test_exceptions_propagate
assert_raise Exception do
template = Liquid::Template.parse( ' {{ errors.exception }} ' )
template.render('errors' => ErrorDrop.new)
end
end
end # ErrorHandlingTest end # ErrorHandlingTest