mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Parse time errors should propagate to calling site
This commit is contained in:
@@ -42,10 +42,12 @@ module Liquid
|
|||||||
def handle_error(e)
|
def handle_error(e)
|
||||||
errors.push(e)
|
errors.push(e)
|
||||||
raise if @rethrow_errors
|
raise if @rethrow_errors
|
||||||
|
|
||||||
case e
|
case e
|
||||||
when SyntaxError then "Liquid syntax error: #{e.message}"
|
when SyntaxError
|
||||||
else "Liquid error: #{e.message}"
|
"Liquid syntax error: #{e.message}"
|
||||||
|
else
|
||||||
|
"Liquid error: #{e.message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -59,15 +59,11 @@ class ErrorHandlingTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_missing_endtag
|
def test_missing_endtag_parse_time_error
|
||||||
|
|
||||||
assert_nothing_raised do
|
assert_raise(Liquid::SyntaxError) do
|
||||||
|
|
||||||
template = Liquid::Template.parse(' {% for a in b %} ... ')
|
template = Liquid::Template.parse(' {% for a in b %} ... ')
|
||||||
assert_equal ' Liquid error: Unknown operator =! ', template.render
|
|
||||||
|
|
||||||
assert_equal 1, template.errors.size
|
|
||||||
assert_equal Liquid::SyntaxError, template.errors.first.class
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user