From 35262aa33c0a9f7d5f76bbf62c205142e4df18f7 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Thu, 2 Sep 2021 16:54:56 +0200 Subject: [PATCH] TMSS-917: raise more specific json decode error --- SAS/TMSS/client/lib/populate.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SAS/TMSS/client/lib/populate.py b/SAS/TMSS/client/lib/populate.py index a1eab1b2c73..1c8e21aeca6 100644 --- a/SAS/TMSS/client/lib/populate.py +++ b/SAS/TMSS/client/lib/populate.py @@ -45,11 +45,12 @@ def populate_schemas(schema_dir: str=None, templates_filename: str=None): # load all templates and schemas and prepare them for upload. # determine the dependencies, and upload the depenends first, and the rest in parallel later. for template in templates: + with open(os.path.join(schema_dir, template['file_name'])) as schema_file: + content = schema_file.read() try: - with open(os.path.join(schema_dir, template['file_name'])) as schema_file: - json_schema = json.loads(schema_file.read()) + json_schema = json.loads(content) except Exception as e: - raise Exception("Could not decode JSON schema %s" % template['file_name']) from e + raise Exception("Could not decode JSON schema file: '%s'\n%s" % (template['file_name'], content)) from e # add template name/description/version from schema if not already in template template['name'] = template.get('name', json_schema.get('title', '<no name>')) -- GitLab