Raise Liquid::ArugmentError when condition has wrong usage

Condition now raises ::ArgumentError when built wrongly.
This patch make it raise Liquid::ArgumentError instead
to indicate a liquid markup error instead of ruby error.
This commit is contained in:
Bogdan Gusiev
2014-04-21 16:42:37 +03:00
parent c098235baa
commit fa14fd02e7
2 changed files with 24 additions and 2 deletions
+6 -2
View File
@@ -94,12 +94,16 @@ module Liquid
left, right = context[left], context[right]
operation = self.class.operators[op] || raise(ArgumentError.new("Unknown operator #{op}"))
operation = self.class.operators[op] || raise(Liquid::ArgumentError.new("Unknown operator #{op}"))
if operation.respond_to?(:call)
operation.call(self, left, right)
elsif left.respond_to?(operation) and right.respond_to?(operation)
left.send(operation, right)
begin
left.send(operation, right)
rescue ::ArgumentError => e
raise Liquid::ArgumentError.new(e.message)
end
else
nil
end