Add handy context to strict parser error messages.

This commit is contained in:
Tristan Hume
2013-08-19 15:45:05 -04:00
parent 324d26d405
commit 0beb4a4793
3 changed files with 26 additions and 3 deletions
+10 -2
View File
@@ -35,11 +35,11 @@ module Liquid
def parse_with_selected_parser(markup)
case @options[:error_mode] || Template.error_mode
when :strict then strict_parse(markup)
when :strict then strict_parse_with_error_context(markup)
when :lax then lax_parse(markup)
when :warn
begin
return strict_parse(markup)
return strict_parse_with_error_context(markup)
rescue SyntaxError => e
@warnings ||= []
@warnings << e
@@ -47,5 +47,13 @@ module Liquid
end
end
end
private
def strict_parse_with_error_context(markup)
strict_parse(markup)
rescue SyntaxError => e
e.message << " in \"#{markup.strip}\""
raise e
end
end # Tag
end # Liquid
+3
View File
@@ -70,6 +70,9 @@ module Liquid
@filters << [filtername, filterargs]
end
p.consume(:end_of_string)
rescue SyntaxError => e
e.message << " in \"{{#{markup}}}\""
raise e
end
def parse_filterargs(p)