From cf2be50b48ae807681d824484674d1303b659aa2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 26 Oct 2019 13:19:34 +0100 Subject: [PATCH] commentjson exceptions --- content.py | 2 +- inbox.py | 2 +- posts.py | 4 ++-- utils.py | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/content.py b/content.py index c8f0c764c..f11b22bdc 100644 --- a/content.py +++ b/content.py @@ -326,7 +326,7 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \ if emojiDictCtr>0: print('emojiDict loaded on try '+str(emojiDictCtr)) break - except Exception as e: + except commentjson.JSONLibraryException as e: print('WARN: commentjson exception addHtmlTags - '+str(e)) print('Failed to load emoji (try '+str(emojiDictCtr)+'): '+baseDir+'/emoji/emoji.json '+str(e)) time.sleep(1) diff --git a/inbox.py b/inbox.py index 48385dabf..9e1791c06 100644 --- a/inbox.py +++ b/inbox.py @@ -1727,7 +1727,7 @@ def runInboxQueue(projectVersion: str, \ try: with open(queueFilename, 'r') as fp: queueJson=commentjson.load(fp) - except Exception as e: + except commentjson.JSONLibraryException as e: itemReadFailed+=1 print('WARN: commentjson exception runInboxQueue - '+str(e)) print('WARN: Failed to load inbox queue item '+queueFilename+' (try '+str(itemReadFailed)+')') diff --git a/posts.py b/posts.py index 1256b472e..f2673647f 100644 --- a/posts.py +++ b/posts.py @@ -1927,7 +1927,7 @@ def createSharedInboxIndex(baseDir: str,sharedBoxDir: str, \ try: with open(sharedInboxFilename, 'r') as fp: postJsonObject=commentjson.load(fp) - except Exception as e: + except commentjson.JSONLibraryException as e: print('WARN: commentjson exception createBoxBase - '+str(e)) continue @@ -1963,7 +1963,7 @@ def createSharedInboxIndex(baseDir: str,sharedBoxDir: str, \ with open(ocapFilename, 'r') as fp: ocapJson=commentjson.load(fp) loadedOcap=True - except Exception as e: + except commentjson.JSONLibraryException as e: print('WARN: commentjson exception createBoxBase - '+str(e)) if loadedOcap: diff --git a/utils.py b/utils.py index 8494eac47..9302f480d 100644 --- a/utils.py +++ b/utils.py @@ -21,8 +21,8 @@ def saveJson(jsonObject: {},filename: str) -> bool: with open(filename, 'w') as fp: commentjson.dump(jsonObject, fp, indent=2, sort_keys=False) return True - except Exception as e: - print(e) + except commentjson.JSONLibraryException as e: + print('WARN: saveJson '+str(e)) time.sleep(1) tries+=1 return False @@ -37,7 +37,7 @@ def loadJson(filename: str) -> {}: with open(filename, 'r') as fp: jsonObject=commentjson.load(fp) break - except Exception as e: + except commentjson.JSONLibraryException as e: print('WARN: loadJson exception - '+str(e)) time.sleep(2) tries+=1 @@ -127,8 +127,8 @@ def getDisplayName(baseDir: str,actor: str,personCache: {}) -> str: with open(cachedActorFilename, 'r') as fp: actorJson=commentjson.load(fp) break - except Exception as e: - print(e) + except commentjson.JSONLibraryException as e: + print('WARN: getDisplayName '+str(e)) time.sleep(1) tries+=1 if actorJson: @@ -300,8 +300,8 @@ def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilena with open(postFilename, 'r') as fp: postJsonObject=commentjson.load(fp) break - except Exception as e: - print(e) + except commentjson.JSONLibraryException as e: + print('WARN: deletePost '+str(e)) time.sleep(1) tries+=1