When prefix and suffix did error checking with positional arguments,
they would not report the position of the argument that failed to
validate. This commit changes the messages to indicate which argument
failed.
array = arguments[0]
unless array.is_a?(Array)
- raise(Puppet::ParseError, 'prefix(): Requires array to work with')
+ raise Puppet::ParseError, "prefix(): expected first argument to be an Array, got #{array.inspect}"
end
prefix = arguments[1] if arguments[1]
if prefix
unless prefix.is_a?(String)
- raise(Puppet::ParseError, 'prefix(): Requires string to work with')
+ raise Puppet::ParseError, "prefix(): expected second argument to be a String, got #{suffix.inspect}"
end
end
array = arguments[0]
unless array.is_a?(Array)
- raise(Puppet::ParseError, 'suffix(): Requires array to work with')
+ raise Puppet::ParseError, "suffix(): expected first argument to be an Array, got #{array.inspect}"
end
suffix = arguments[1] if arguments[1]
if suffix
- unless suffix.is_a?(String)
- raise(Puppet::ParseError, 'suffix(): Requires string to work with')
+ unless suffix.is_a? String
+ raise Puppet::ParseError, "suffix(): expected second argument to be a String, got #{suffix.inspect}"
end
end