Please review pull request #738: Ticket/2.7.x/14296 opened by (nanliu)

Description:

The current template function does not provide sufficient detail for
troubleshooting. This patch uses the backtrace to provide the fully
qualified filepath and line number.

Previous error message:
Failed to parse template test/example.erb: undefined method `[]' for
nil:NilClass at /tmp/module/test/manifests/init.pp:2 on node example

New error message:
Failed to parse template test/example.erb:
Filepath: /tmp/module/test/templates/example.erb
Line: 10
Detail: undefined method `[]' for nil:NilClass
at /tmp/module/test/manifests/init.pp:2 on node example

  • Opened: Thu May 03 14:47:56 UTC 2012
  • Based on: puppetlabs:2.7.x (94dee104ddb833482ce2356ab3aa33fa9d3d5fb2)
  • Requested merge: nanliu:ticket/2.7.x/14296 (0efb4c254de3139e362bb0963a3f9e2edb74b016)

Diff follows:

diff --git a/lib/puppet/parser/functions/template.rb b/lib/puppet/parser/functions/template.rb
index 6fa1103..8105e2c 100644
--- a/lib/puppet/parser/functions/template.rb
+++ b/lib/puppet/parser/functions/template.rb
@@ -17,8 +17,9 @@
       begin
         wrapper.result
       rescue => detail
+        info = detail.backtrace.first.split(':')
         raise Puppet::ParseError,
-          "Failed to parse template #{file}: #{detail}"
+          "Failed to parse template #{file}:\n  Filepath: #{info[0]}\n  Line: #{info[1]}\n  Detail: #{detail}\n"
       end
     end.join("")
 end

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to