From 7f99f91933f71dfeeea6809749b1b993e69e7265 Mon Sep 17 00:00:00 2001 From: gryf Date: Thu, 2 Sep 2021 18:36:57 +0200 Subject: [PATCH] Fail on yaml parse errors --- box.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/box.py b/box.py index 439724d..a6e2305 100755 --- a/box.py +++ b/box.py @@ -1066,6 +1066,10 @@ def vmcreate(args, conf=None): conf = Config(args) except BoxNotFound: return 7 + except yaml.YAMLError: + LOG.fatal(f'Cannot read or parse file `{args.config}` as YAML ' + f'file') + return 14 LOG.header('Creating VM: %s', conf.name) vbox = VBoxManage(conf.name) @@ -1255,6 +1259,10 @@ def vmrebuild(args): conf = Config(args, vbox) except BoxNotFound: return 8 + except yaml.YAMLError: + LOG.fatal(f'Cannot read or parse file `{args.config}` as YAML ' + f'file') + return 15 vbox.poweroff() @@ -1288,6 +1296,10 @@ def connect(args): conf = Config(args, vbox) except BoxNotFound: return 11 + except yaml.YAMLError: + LOG.fatal(f'Cannot read or parse file `{args.config}` as YAML ' + f'file.') + return 16 return Run(['ssh', '-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null',