mirror of
https://github.com/Shopify/liquid.git
synced 2025-09-11 00:00:13 -04:00
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:
parent
0526348cae
commit
4fec29f288
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user