Issue #22730 has been updated by Hunter Haugen.

One quick hack I had was to modify `lib/puppet/parser/functions.rb` with this 
patch to throw the first line of the backtrace, giving the full path to the 
`.rb` file that raised the exception:

    diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
    index 7015ec4..245f86e 100644
    --- a/lib/puppet/parser/functions.rb
    +++ b/lib/puppet/parser/functions.rb
    @@ -144,7 +144,11 @@ module Puppet::Parser::Functions
               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])
    +          begin
    +            self.send(real_fname, args[0])
    +          rescue => e
    +            raise Puppet::Error, "#{e.message}\nSource: 
#{e.backtrace.first}"
    +          end
             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


----------------------------------------
Bug #22730: Wrapped exceptions of functions are still hiding that they were 
raised in a function
https://projects.puppetlabs.com/issues/22730#change-98425

* 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.

Reply via email to