mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 10:52:48 -07:00
Translate exceptions in filters to Liquid::FilterError errors.
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user