introduce unhandled liquid exception

check arity
This commit is contained in:
Richard Monette
2016-10-21 13:27:54 -04:00
parent 43e59796f6
commit a549d289d7
2 changed files with 6 additions and 4 deletions

View File

@@ -93,10 +93,10 @@ module Liquid
rescue MemoryError => e
raise e
rescue UndefinedVariable, UndefinedDropMethod, UndefinedFilter => e
context.handle_error(e, token.line_number)
context.handle_error(e, token.line_number, token.raw)
output << nil
rescue ::StandardError => e
output << context.handle_error(e, token.line_number)
output << context.handle_error(e, token.line_number, token.raw)
end
end

View File

@@ -73,7 +73,7 @@ module Liquid
@interrupts.pop
end
def handle_error(e, line_number = nil)
def handle_error(e, line_number = nil, raw_token = nil)
if e.is_a?(Liquid::Error)
e.template_name ||= template_name
e.line_number ||= line_number
@@ -82,7 +82,9 @@ module Liquid
output = nil
if exception_handler
result = exception_handler.call(e)
args = [e]
args << { line_number: line_number, raw_token: raw_token } if exception_handler.arity == 2
result = exception_handler.call(*args)
case result
when Exception
e = result