summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Thebo <git@somethingsinistral.net>2013-03-27 13:37:25 -0700
committerAdrien Thebo <git@somethingsinistral.net>2013-03-27 13:37:25 -0700
commit29402f31e73a426dcc449216010834884d0251ec (patch)
tree5b7751a1d154dcbb86f3bcb7d78a5e65b59fbdac
parenta83318d3ee41683118a55a2b15769c97efbcf6d9 (diff)
(maint) better error reporting for prefix and suffix
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.
-rw-r--r--lib/puppet/parser/functions/prefix.rb4
-rw-r--r--lib/puppet/parser/functions/suffix.rb6
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/puppet/parser/functions/prefix.rb b/lib/puppet/parser/functions/prefix.rb
index 243cf18..62211ae 100644
--- a/lib/puppet/parser/functions/prefix.rb
+++ b/lib/puppet/parser/functions/prefix.rb
@@ -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
diff --git a/lib/puppet/parser/functions/suffix.rb b/lib/puppet/parser/functions/suffix.rb
index 5018280..f7792d6 100644
--- a/lib/puppet/parser/functions/suffix.rb
+++ b/lib/puppet/parser/functions/suffix.rb
@@ -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