summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-08-29 23:27:27 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-08-29 23:27:27 +0000
commit6f175ce41fa4a7a62783c173965683c87c61095b (patch)
tree794b48889428a1115e01b1f6ca287a1dbfac3354 /lib
parenta46a620486b106ffc8e653b48a1de58ca6a64933 (diff)
downloadpuppet-6f175ce41fa4a7a62783c173965683c87c61095b.tar.gz
puppet-6f175ce41fa4a7a62783c173965683c87c61095b.tar.xz
puppet-6f175ce41fa4a7a62783c173965683c87c61095b.zip
Adding automatic stacktrace printing to deverror. I need to go through and remove the redundant puts in the rest of the code, but I need this now for some client debugging
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1515 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/error.rb17
-rw-r--r--lib/puppet/parser/ast.rb5
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/puppet/error.rb b/lib/puppet/error.rb
index fb22a65d3..b06c9ffc7 100644
--- a/lib/puppet/error.rb
+++ b/lib/puppet/error.rb
@@ -14,8 +14,11 @@ module Puppet # :nodoc:
end
end
- def initialize(message)
+ def initialize(message, line = nil, file = nil)
@message = message
+
+ @line = line if line
+ @file = file if file
end
def to_s
@@ -34,7 +37,17 @@ module Puppet # :nodoc:
end
end
- class DevError < Error; end
+ # An error class for when I don't know what happened. Automatically
+ # prints a stack trace when in debug mode.
+ class DevError < Error
+ # XXX This is probably the wrong way to do this, but...
+ def set_backtrace(trace)
+ if Puppet[:debug]
+ puts trace
+ end
+ super(trace)
+ end
+ end
end
# $Id$
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb
index 06798b44d..a4375a476 100644
--- a/lib/puppet/parser/ast.rb
+++ b/lib/puppet/parser/ast.rb
@@ -79,10 +79,7 @@ module Puppet
)
error.line ||= @line
error.file ||= @file
- error.backtrace = detail.backtrace
- if Puppet[:debug]
- puts detail.backtrace
- end
+ error.set_backtrace detail.backtrace
raise error
end
end