diff --git a/lib/liquid/block.rb b/lib/liquid/block.rb index 10df350..b16de4c 100644 --- a/lib/liquid/block.rb +++ b/lib/liquid/block.rb @@ -92,7 +92,7 @@ module Liquid list.collect do |token| begin token.respond_to?(:render) ? token.render(context) : token - rescue Exception => e + rescue ::StandardError => e context.handle_error(e) end end diff --git a/test/lib/liquid/error_handling_test.rb b/test/lib/liquid/error_handling_test.rb index e561e3d..22603bb 100644 --- a/test/lib/liquid/error_handling_test.rb +++ b/test/lib/liquid/error_handling_test.rb @@ -13,6 +13,10 @@ class ErrorDrop < Liquid::Drop raise Liquid::SyntaxError, 'syntax error' end + def exception + raise Exception, 'exception' + end + end class ErrorHandlingTest < Test::Unit::TestCase @@ -66,4 +70,12 @@ class ErrorHandlingTest < Test::Unit::TestCase assert_equal Liquid::ArgumentError, template.errors.first.class 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