better error message
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
3e3919d15f
commit
d346364544
1 changed files with 4 additions and 3 deletions
|
@ -34,11 +34,12 @@ DOT_CDIST = '.cdist'
|
||||||
|
|
||||||
|
|
||||||
class IllegalObjectIdError(cdist.Error):
|
class IllegalObjectIdError(cdist.Error):
|
||||||
def __init__(self, object_id):
|
def __init__(self, object_id, message=None):
|
||||||
self.object_id = object_id
|
self.object_id = object_id
|
||||||
|
self.message = message or 'Illegal object id'
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'Illegal object id: %s' % self.object_id
|
return '%s: %s' % (self.message, self.object_id)
|
||||||
|
|
||||||
|
|
||||||
class Object(object):
|
class Object(object):
|
||||||
|
@ -88,7 +89,7 @@ class Object(object):
|
||||||
|
|
||||||
def __init__(self, cdist_type, base_path, object_id=None):
|
def __init__(self, cdist_type, base_path, object_id=None):
|
||||||
if object_id and object_id.startswith('/'):
|
if object_id and object_id.startswith('/'):
|
||||||
raise IllegalObjectIdError(object_id)
|
raise IllegalObjectIdError(object_id, 'object_id may not start with /')
|
||||||
self.type = cdist_type # instance of Type
|
self.type = cdist_type # instance of Type
|
||||||
self.base_path = base_path
|
self.base_path = base_path
|
||||||
self.object_id = object_id
|
self.object_id = object_id
|
||||||
|
|
Loading…
Reference in a new issue