]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
(maint) better error reporting for prefix and suffix
authorAdrien Thebo <git@somethingsinistral.net>
Wed, 27 Mar 2013 20:37:25 +0000 (13:37 -0700)
committerAdrien Thebo <git@somethingsinistral.net>
Wed, 27 Mar 2013 20:37:25 +0000 (13:37 -0700)
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.

lib/puppet/parser/functions/prefix.rb
lib/puppet/parser/functions/suffix.rb

index 243cf1807ae8f2f1d2e996cbee769b652b72681d..62211ae684204d01817d87a85cfd5b52b59e3f02 100644 (file)
@@ -21,14 +21,14 @@ Will return: ['pa','pb','pc']
     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
 
index 50182809f8926238bd092343b84ff7795b56c5c2..f7792d6f7a661647906dfea85dc8c6529dedaf07 100644 (file)
@@ -21,14 +21,14 @@ Will return: ['ap','bp','cp']
     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