diff --git a/cdist/emulator.py b/cdist/emulator.py index af4c620e..22c819cd 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -28,7 +28,14 @@ import sys import cdist from cdist import core -class MissingEnvironmentVariable(cdist.Error): +class MissingRequiredEnvironmentVariableError(cdist.Error): + def __init__(self, name): + self.name = name + self.message = "Emulator requires the environment variable %s to be setup" % self.name + + def __str__(self): + return self.message + class Emulator(object): def __init__(self, argv, stdin=sys.stdin.buffer, env=os.environ): @@ -46,7 +53,8 @@ class Emulator(object): self.object_source = self.env['__cdist_manifest'] self.type_base_path = self.env['__cdist_type_base_path'] - except KeyError: + except KeyError as e: + raise MissingRequiredEnvironmentVariableError(e.args[0]) self.object_base_path = os.path.join(self.global_path, "object")