From 815cd2eb7193d5b484290b341b80b7162851ff98 Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Thu, 24 Nov 2016 13:20:30 +0100 Subject: [PATCH] Improved form config loading error message --- src/scriptform.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/scriptform.py b/src/scriptform.py index c91fe65..c303351 100755 --- a/src/scriptform.py +++ b/src/scriptform.py @@ -84,7 +84,12 @@ class ScriptForm(object): if self.cache and self.form_config_singleton is not None: return self.form_config_singleton - config = json.load(file(self.config_file, 'r')) + file_contents = file(self.config_file, 'r').read() + try: + config = json.loads(file_contents) + except ValueError as e: + sys.stderr.write("Error in form configuration '{}': {}\n".format(self.config_file, e)) + sys.exit(1) static_dir = None custom_css = None