From 1c84e423d11b9535a940ed9f76f8e69a3b2ff40e Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 14 Oct 2011 11:49:37 +0200 Subject: [PATCH] include type name in error message Signed-off-by: Steven Armstrong --- lib/cdist/core/object.py | 7 ++++--- lib/cdist/emulator.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/cdist/core/object.py b/lib/cdist/core/object.py index eeb5799b..60ae59f4 100644 --- a/lib/cdist/core/object.py +++ b/lib/cdist/core/object.py @@ -34,12 +34,13 @@ DOT_CDIST = '.cdist' class IllegalObjectIdError(cdist.Error): - def __init__(self, object_id, message=None): + def __init__(self, object_id, type_name, message=None): self.object_id = object_id + self.type_name = type_name self.message = message or 'Illegal object id' def __str__(self): - return '%s: %s' % (self.message, self.object_id) + return '%s: %s' % (self.message, os.path.join(self.type_name. self.object_id)) class Object(object): @@ -89,7 +90,7 @@ class Object(object): def __init__(self, cdist_type, base_path, object_id=None): if object_id and object_id.startswith('/'): - raise IllegalObjectIdError(object_id, 'object_id may not start with /') + raise IllegalObjectIdError(object_id, cdist_type.name, 'object_id may not start with /') self.type = cdist_type # instance of Type self.base_path = base_path self.object_id = object_id diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py index ca65e731..f37c3169 100644 --- a/lib/cdist/emulator.py +++ b/lib/cdist/emulator.py @@ -116,9 +116,9 @@ def run(argv): # no object id, must be singleton requirement_object_id = 'singleton' if requirement_object_id.startswith('/'): - raise core.IllegalObjectIdError(requirement_object_id, 'object_id may not start with /') + raise core.IllegalObjectIdError(requirement_object_id, requirement_type_name, 'object_id may not start with /') log.debug("Recording requirement: %s -> %s" % (cdist_object.path, requirement)) - cdist_object.requirements.append(rement_object_id) + cdist_object.requirements.append(requirement) # Record / Append source cdist_object.source.append(object_source)