From d671c148fe001f1f995908f9023e2efa43cbbf0f Mon Sep 17 00:00:00 2001 From: Stuart Langridge Date: Tue, 4 Jun 2019 14:38:48 +0100 Subject: Don't explode if the settings file is somehow invalid (fixes #3) --- magnus | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/magnus b/magnus index f05d02d..47dbba9 100755 --- a/magnus +++ b/magnus @@ -224,7 +224,11 @@ class Main(object): print("couldn't restore settings (error: %s), so assuming they're blank" % (e,)) contents = "{}" # fake contents - data = json.loads(contents) + try: + data = json.loads(contents) + except Exception as e: + print("Warning: settings file seemed to be invalid json (error: %s), so assuming blank" % (e,)) + data = {} zl = data.get("zoom") if zl: idx = 0 -- cgit