From 380f186273b4b7e045c76b0078b091063347aef6 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 17 Sep 2015 14:42:43 +0100 Subject: [PATCH] Log which file a json parse error occurred in --- templating/matrix_templates/units.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/templating/matrix_templates/units.py b/templating/matrix_templates/units.py index 6bb9b7d7..4b8127ae 100644 --- a/templating/matrix_templates/units.py +++ b/templating/matrix_templates/units.py @@ -290,8 +290,14 @@ class MatrixUnits(Units): continue event_type = filename[:-5] # strip the ".json" - with open(os.path.join(root, filename)) as f: - event_info = json.loads(f.read()) + filepath = os.path.join(root, filename) + with open(filepath) as f: + try: + event_info = json.load(f) + except Exception as e: + raise ValueError( + "Error reading file %r" % (filepath,), e + ) if "event" not in event_type: continue # filter ImageInfo and co