summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-07-23 18:48:18 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-07-31 16:41:41 +1000
commit832b6ff1e18cf403213cbeb42646b5740669e6a5 (patch)
tree4866da8e9748d75ca113c6a1a783ee3f8f763350 /lib/puppet
parent4ea3f17eee236bcbc4481b08eeb5ece1e51cc929 (diff)
downloadpuppet-832b6ff1e18cf403213cbeb42646b5740669e6a5.tar.gz
puppet-832b6ff1e18cf403213cbeb42646b5740669e6a5.tar.xz
puppet-832b6ff1e18cf403213cbeb42646b5740669e6a5.zip
Exiting from app failures instead of raising
This protects the user from seeing stack traces in normal situations. It makes sense here because this is explicitly for user interactions. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/application.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index e7240f773..2882c8191 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -210,11 +210,11 @@ class Puppet::Application
# This is the main application entry point
def run
- run_preinit
- parse_options
- Puppet.settings.parse if should_parse_config?
- run_setup
- run_command
+ exit_on_fail("initialize") { run_preinit }
+ exit_on_fail("parse options") { parse_options }
+ exit_on_fail("parse configuration file") { Puppet.settings.parse } if should_parse_config?
+ exit_on_fail("prepare for execution") { run_setup }
+ exit_on_fail("run") { run_command }
end
def main
@@ -299,4 +299,15 @@ class Puppet::Application
end
end
+ private
+
+ def exit_on_fail(message, code = 1)
+ begin
+ yield
+ rescue RuntimeError, NotImplementedError => detail
+ puts detail.backtrace if Puppet[:trace]
+ $stderr.puts "Could not %s: %s" % [message, detail]
+ exit(code)
+ end
+ end
end