Translate exceptions in filters to Liquid::FilterError errors.

This commit is contained in:
Dylan Thacker-Smith
2015-05-25 15:22:12 -04:00
parent 8af99ff918
commit 169dfe5af3
4 changed files with 34 additions and 7 deletions
+4
View File
@@ -49,6 +49,10 @@ module Liquid
end
end
class FilterError < Error
attr_accessor :original_exception
end
ArgumentError = Class.new(Error)
ContextError = Class.new(Error)
FileSystemError = Class.new(Error)
+11 -3
View File
@@ -47,12 +47,20 @@ module Liquid
def invoke(method, *args)
if self.class.invokable?(method)
send(method, *args)
begin
send(method, *args)
rescue ::ArgumentError => e
raise Liquid::ArgumentError.new(e.message)
rescue Liquid::Error
raise
rescue ::StandardError => exception
error = Liquid::FilterError.new(exception.message)
error.original_exception = exception
raise error
end
else
args.first
end
rescue ::ArgumentError => e
raise Liquid::ArgumentError.new(e.message)
end
end
end