Implement friendlier error handling.

Generic AnsibleError exception + host inventory missing exception.
First shot at catching these in a generic way in bin/ansible*.
This commit is contained in:
Tim Bielawa
2012-03-12 23:11:54 -04:00
parent ce85222fa6
commit dfd2c6dce3
4 changed files with 57 additions and 10 deletions

View File

@@ -34,6 +34,7 @@ import ansible.runner
import ansible.playbook
import ansible.constants as C
from ansible.utils import *
from ansible.errors import *
########################################################
@@ -193,7 +194,11 @@ class Cli(object):
if __name__ == '__main__':
cli = Cli()
(options, args) = cli.parse()
(runner, results) = cli.run(options, args)
cli.output(runner, results, options, args)
try:
(runner, results) = cli.run(options, args)
except AnsibleError as e:
# Generic handler for ansible specific errors
print e
sys.exit(1)
else:
cli.output(runner, results, options, args)