forked from ungleich-public/cdist
invent a generic CdistObjectError and point to definition source (easier debugging)
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
0861276436
commit
d51a177a95
2 changed files with 13 additions and 1 deletions
|
@ -44,6 +44,18 @@ class Error(Exception):
|
||||||
"""Base exception class for this project"""
|
"""Base exception class for this project"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class CdistObjectError(Error):
|
||||||
|
"""Something went wrong with an object"""
|
||||||
|
|
||||||
|
def __init__(self, cdist_object, message):
|
||||||
|
self.name = cdist_object.name
|
||||||
|
self.source = " ".join(cdist_object.source)
|
||||||
|
self.message = message
|
||||||
|
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return '%s: %s (defined at %s)' % (self.name, self.message, self.source)
|
||||||
|
|
||||||
def file_to_list(filename):
|
def file_to_list(filename):
|
||||||
"""Return list from \n seperated file"""
|
"""Return list from \n seperated file"""
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
|
|
|
@ -125,7 +125,7 @@ class DependencyResolver(object):
|
||||||
resolved.append(cdist_object)
|
resolved.append(cdist_object)
|
||||||
unresolved.remove(cdist_object)
|
unresolved.remove(cdist_object)
|
||||||
except RequirementNotFoundError as e:
|
except RequirementNotFoundError as e:
|
||||||
raise cdist.Error(cdist_object.name + " requires non-existing " + e.requirement)
|
raise cdist.CdistObjectError(cdist_object, "requires non-existing " + e.requirement)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
"""Iterate over all unique objects while resolving dependencies.
|
"""Iterate over all unique objects while resolving dependencies.
|
||||||
|
|
Loading…
Reference in a new issue