Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cfbs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
elsewhere, like validation and downloading modules.
"""

import json
import os
import logging as log
import shutil
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be a good idea to explain what out/... especially in this case.

e.g.

"Error parsing built augment file: out/masterfiles/def.json" or something similar.

We should probably parse all the json files processed by the "json" command individually and error out on those instead so the user can just go to the file directly. I feel like mentioning "out" dir might be confusing to a novice user.

)
print("")
print("Generating tarball...")
sh("( cd out/ && tar -czf masterfiles.tgz masterfiles )")
Expand Down
2 changes: 1 addition & 1 deletion cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down