Issue #22730 has been updated by Sean Ellefson.
Status changed from Unreviewed to Investigating
Assignee set to Hunter Haugen
Still need to recreate steps and confirm, although after some cursory scans of
the code, Hunner suggests returning a rescue wrapped around the originally
accepted block, rather than returning the block itself found under
<pre>/puppet/blob/master/lib/puppet/parser/functions.rb:130..149</pre>
<pre>
# the block must be installed as a method because it may use "return",
# which is not allowed from procs.
real_fname = "real_function_#{name}"
environment_module.send(:define_method, real_fname, &block)
fname = "function_#{name}"
environment_module.send(:define_method, fname) do |*args|
Puppet::Util::Profiler.profile("Called #{name}") do
if args[0].is_a? Array
if arity >= 0 and args[0].size != arity
raise ArgumentError, "#{name}(): Wrong number of arguments given
(#{args[0].size} for #{arity})"
elsif arity < 0 and args[0].size < (arity+1).abs
raise ArgumentError, "#{name}(): Wrong number of arguments given
(#{args[0].size} for minimum #{(arity+1).abs})"
end
self.send(real_fname, args[0])
else
raise ArgumentError, "custom functions must be called with a single
array that contains the arguments. For example, function_example([1]) instead
of function_example(1)"
end
end
end
</pre>
----------------------------------------
Bug #22730: Wrapped exceptions of functions are still hiding that they were
raised in a function
https://projects.puppetlabs.com/issues/22730#change-98403
* Author: Peter Meier
* Status: Investigating
* Priority: Normal
* Assignee: Hunter Haugen
* Category: error reporting
* Target version:
* Affected Puppet version: 3.3.0
* Keywords:
* Branch:
----------------------------------------
As noted in #22729 the source of an exception that is thrown in a function, is
still completely hidden to the user in the output:
<pre>
# puppet --version
3.3.0
# puppet apply -e "notice reject(['a','b'],'b')"
Error: reject(): wrong argument type (String; must be a parameterized block. at
line 1 on node foo
Wrapped exception:
reject(): wrong argument type (String; must be a parameterized block.
Error: reject(): wrong argument type (String; must be a parameterized block. at
line 1 on node foo
</pre>
There is no way that I can see that this exception was actually raised in the
function itself and I need to use `--trace` to see the actual source of the
problem. Also the actual Error and the wrapped exception output look identical
to me and it makes no sense to have this output doubled.
As a user I'd like to be able to:
1. See the message of the raised exception
2. See the actual source of the raised exception (in the case above the
function reject).
Otherwise we should not output the wrapped exception at all, because it makes
the output very confusing.
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.