Upgrades to error handling, now general try/catch available.

This commit is contained in:
Michael DeHaan 2012-03-13 20:59:05 -04:00
commit 4ae98ed92d
5 changed files with 92 additions and 52 deletions

View file

@ -20,18 +20,18 @@ class AnsibleError(Exception):
"""
The base Ansible exception from which all others should subclass.
"""
def __init__(self, msg):
self.msg = msg
def __str__(self):
return self.msg
class AnsibleFileNotFound(AnsibleError):
pass
class AnsibleConnectionFailed(AnsibleError):
pass
class AnsibleInventoryNotFoundError(AnsibleError):
"""
Exception raised when the default or provided host inventory file
does not exist.
"""
def __init__(self, inventory):
self.inventory = inventory
self.msg = "Unable to continue, inventory file not found: %s" %\
self.inventory
def __str__(self):
return self.msg