From 4104bd3ee9fa146b49aa446fbf4cc3edcdf0974d Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 6 Sep 2007 19:24:25 -0500 Subject: Fixing #807. The exception handling should more closely resemble how it used to be done. --- lib/puppet/network/handler/configuration.rb | 4 +++- lib/puppet/parser/interpreter.rb | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/puppet/network/handler/configuration.rb b/lib/puppet/network/handler/configuration.rb index 05c86f22e..2c72d3d2b 100644 --- a/lib/puppet/network/handler/configuration.rb +++ b/lib/puppet/network/handler/configuration.rb @@ -111,7 +111,9 @@ class Puppet::Network::Handler if Puppet[:trace] puts detail.backtrace end - Puppet.err detail + unless local? + Puppet.err detail.to_s + end raise XMLRPC::FaultException.new( 1, detail.to_s ) diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index 93a4bc170..a4ea26572 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -77,20 +77,27 @@ class Puppet::Parser::Interpreter if Puppet[:trace] puts detail.backtrace end - Puppet.err "Could not parse for environment %s: %s" % [environment, detail] - return nil + msg = "Could not parse" + if environment and environment != "" + msg += " for environment %s" % environment + end + msg += ": %s" % detail + raise Puppet::Error, detail end end # Return the parser for a specific environment. def parser(environment) if ! @parsers[environment] or @parsers[environment].reparse? - if tmp = create_parser(environment) + # This will throw an exception if it does not succeed. We only + # want to get rid of the old parser if we successfully create a new + # one. + begin + tmp = create_parser(environment) @parsers[environment].clear if @parsers[environment] @parsers[environment] = tmp - end - unless @parsers[environment] - raise Puppet::Error, "Could not parse any configurations" + rescue + # Nothing, yo. end end @parsers[environment] -- cgit