Skip to content

Commit d154a03

Browse files
authored
Improved reporting of JSON parsing failures.
1 parent ac3b835 commit d154a03

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/cmdlinejsonvalidator.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ def jsonvalidation(json_doc_path, json_schema_path):
3737

3838
# Open the file for reading
3939
with open(json_doc_path, 'r') as fp:
40-
json_doc = json.load(fp)
40+
try:
41+
json_doc = json.load(fp)
42+
except ValueError as err:
43+
sys.stderr.write("Failed to parse JSON : \n")
44+
sys.stderr.write(" " + str(err) + "\n")
45+
raise SystemExit
4146

4247
try:
4348
validate(json_doc, schema_doc)

0 commit comments

Comments
 (0)