diff options
author | Luke Kanies <luke@madstop.com> | 2007-10-03 17:31:57 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-10-03 17:31:57 -0500 |
commit | 5d50ca790e7f752e07da84197b52ff84d2dcfdb4 (patch) | |
tree | e2a6da756a53347ed5d33de7f89040222279a449 /lib | |
parent | b727a95aa4b72ce057653101cf1f50fa49c4b0a8 (diff) | |
download | puppet-5d50ca790e7f752e07da84197b52ff84d2dcfdb4.tar.gz puppet-5d50ca790e7f752e07da84197b52ff84d2dcfdb4.tar.xz puppet-5d50ca790e7f752e07da84197b52ff84d2dcfdb4.zip |
Fixing #814 -- when files are missing, the exceptions should
now be more reasonable.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/error.rb | 7 | ||||
-rw-r--r-- | lib/puppet/network/handler/configuration.rb | 17 | ||||
-rw-r--r-- | lib/puppet/network/handler/master.rb | 7 | ||||
-rw-r--r-- | lib/puppet/parser/interpreter.rb | 19 |
4 files changed, 19 insertions, 31 deletions
diff --git a/lib/puppet/error.rb b/lib/puppet/error.rb index 55fbf2e2f..971b31116 100644 --- a/lib/puppet/error.rb +++ b/lib/puppet/error.rb @@ -41,12 +41,5 @@ module Puppet # :nodoc: # An error class for when I don't know what happened. Automatically # prints a stack trace when in debug mode. class DevError < Puppet::Error - # XXX This is probably the wrong way to do this, but... - def set_backtrace(trace) - if Puppet[:trace] - puts trace - end - super - end end end diff --git a/lib/puppet/network/handler/configuration.rb b/lib/puppet/network/handler/configuration.rb index 2df1b3ab4..353693bdc 100644 --- a/lib/puppet/network/handler/configuration.rb +++ b/lib/puppet/network/handler/configuration.rb @@ -107,16 +107,13 @@ class Puppet::Network::Handler benchmark(level, "Compiled configuration for %s" % node.name) do begin config = interpreter.compile(node) - rescue Puppet::Error => detail - if Puppet[:trace] - puts detail.backtrace - end - unless local? - Puppet.err detail.to_s - end - raise XMLRPC::FaultException.new( - 1, detail.to_s - ) + rescue => detail + # If we're local, then we leave it to the local system + # to handle error reporting, but otherwise we do it here + # so the interpreter doesn't need to know if the parser + # is local or not. + Puppet.err(detail.to_s) unless local? + raise end end diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb index 030950c61..25c4318b8 100644 --- a/lib/puppet/network/handler/master.rb +++ b/lib/puppet/network/handler/master.rb @@ -77,12 +77,7 @@ class Puppet::Network::Handler Puppet::Node::Facts.new(client, facts).save # And get the configuration from the config handler - begin - config = config_handler.configuration(client) - rescue => detail - puts detail.backtrace - raise - end + config = config_handler.configuration(client) return translate(config.extract) end diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index 81867c84b..0b8c035ba 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -25,7 +25,8 @@ class Puppet::Parser::Interpreter # evaluate our whole tree def compile(node) - return Puppet::Parser::Compile.new(node, parser(node.environment), :ast_nodes => usenodes?).compile + raise Puppet::ParseError, "Could not parse configuration; cannot compile" unless env_parser = parser(node.environment) + return Puppet::Parser::Compile.new(node, env_parser, :ast_nodes => usenodes?).compile end # create our interpreter @@ -74,15 +75,14 @@ class Puppet::Parser::Interpreter parser.parse return parser rescue => detail - if Puppet[:trace] - puts detail.backtrace - end msg = "Could not parse" if environment and environment != "" msg += " for environment %s" % environment end - msg += ": %s" % detail - raise Puppet::Error, detail + msg += ": %s" % detail.to_s + error = Puppet::Error.new(msg) + error.set_backtrace(detail.backtrace) + raise error end end @@ -96,8 +96,11 @@ class Puppet::Parser::Interpreter tmp = create_parser(environment) @parsers[environment].clear if @parsers[environment] @parsers[environment] = tmp - rescue - # Nothing, yo. + rescue => detail + # If a parser already exists, than assume that we logged the + # exception elsewhere and reuse the parser. If one doesn't + # exist, then reraise. + raise detail unless @parsers[environment] end end @parsers[environment] |