diff --git a/cfbs/build.py b/cfbs/build.py index cf33d7ce..7c295fbd 100644 --- a/cfbs/build.py +++ b/cfbs/build.py @@ -10,6 +10,7 @@ elsewhere, like validation and downloading modules. """ +import json import os import logging as log import shutil @@ -485,7 +486,12 @@ def perform_build(config: CFBSConfig, diffs_filename=None) -> int: assert os.path.isdir("./out/masterfiles/") shutil.copyfile("./cfbs.json", "./out/masterfiles/cfbs.json") if os.path.isfile("out/masterfiles/def.json"): - pretty_file("out/masterfiles/def.json") + try: + pretty_file("out/masterfiles/def.json") + except json.decoder.JSONDecodeError as e: + raise CFBSExitError( + "Error parsing JSON in 'out/masterfiles/def.json': %s" % e + ) print("") print("Generating tarball...") sh("( cd out/ && tar -czf masterfiles.tgz masterfiles )") diff --git a/cfbs/commands.py b/cfbs/commands.py index fbeb277c..63491d92 100644 --- a/cfbs/commands.py +++ b/cfbs/commands.py @@ -176,7 +176,7 @@ def pretty_command(filenames: List[str], check: bool, keep_order: bool): except FileNotFoundError: raise CFBSExitError("File '%s' not found" % f) except json.decoder.JSONDecodeError as ex: - raise CFBSExitError("Error reading json file '{}': {}".format(f, ex)) + raise CFBSExitError("Error parsing JSON in '%s': %s" % (f, ex)) if check: print("Would reformat %d file(s)" % num_files) return 1 if num_files > 0 else 0