throw a better exception when environment variables are missing
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
2f5de23ae9
commit
866645679a
1 changed files with 10 additions and 2 deletions
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in a new issue