Skip to content

Commit 353da69

Browse files
committed
explicitly name invalid json
1 parent d31d19d commit 353da69

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

heudiconv/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,13 @@ def load_json(filename):
172172
-------
173173
data : dict
174174
"""
175-
with open(filename, 'r') as fp:
176-
data = json.load(fp)
177-
return data
175+
try:
176+
with open(filename, 'r') as fp:
177+
data = json.load(fp)
178+
except json.JSONDecodeError:
179+
print("{fname} is not a valid json file".format(fname=filename))
180+
raise
181+
178182

179183

180184
def assure_no_file_exists(path):

0 commit comments

Comments
 (0)