From aee83605ab63a7138c3727aa3458d0d6d9bb15ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barrabin=20Fc=2E=20=E2=9A=91?= Date: Thu, 3 Mar 2016 20:40:26 -0300 Subject: [PATCH] Added exception handling for invalid dbschema.json files --- src/Site/SiteStorage.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Site/SiteStorage.py b/src/Site/SiteStorage.py index 03110280..f0e0057c 100644 --- a/src/Site/SiteStorage.py +++ b/src/Site/SiteStorage.py @@ -34,8 +34,12 @@ class SiteStorage: # Load db from dbschema.json def openDb(self, check=True): - schema = self.loadJson("dbschema.json") - db_path = self.getPath(schema["db_file"]) + try: + schema = self.loadJson("dbschema.json") + db_path = self.getPath(schema["db_file"]) + except Exception, err: + raise Exception("dbschema.json is not a valid JSON: %s", err) + if check: if not os.path.isfile(db_path) or os.path.getsize(db_path) == 0: # Not exist or null self.rebuildDb()