Rescue and re-raise syntax errors in Template#parse to add line numbers.

This can be done now that the parse context has the line number
information, so it doesn't need to be added on closer to the original
exception.  This has the advantage of not having to rescue and re-raise the
exception multiple times, and simplifies liquid-c which would otherwise
have to rescue the exception in BlockBody#parse.
This commit is contained in:
Dylan Thacker-Smith
2015-07-08 19:21:59 -04:00
parent cebf75b8d7
commit 920e1df643
3 changed files with 25 additions and 27 deletions
+1 -1
View File
@@ -8,7 +8,6 @@ module Liquid
begin
return strict_parse_with_error_context(markup)
rescue SyntaxError => e
e.line_number = line_number
@options.warnings << e
return lax_parse(markup)
end
@@ -20,6 +19,7 @@ module Liquid
def strict_parse_with_error_context(markup)
strict_parse(markup)
rescue SyntaxError => e
e.line_number = line_number
e.markup_context = markup_context(markup)
raise e
end