summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-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