From 2770750cae44d69fb2e56a282b5d650243eeee70 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Thu, 15 Aug 2019 13:28:04 +0200 Subject: [PATCH] Handle deleted posts --- jan-pona-mute.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jan-pona-mute.py b/jan-pona-mute.py index 81236f1..8366ed5 100755 --- a/jan-pona-mute.py +++ b/jan-pona-mute.py @@ -316,7 +316,8 @@ post again.""" if self.numbers_refer_to == 'notifications': notification = self.notifications[n-1] self.show(notification) - self.load(notification.about()) + if not self.load(notification.about()): + return elif self.numbers_refer_to == 'home': posts = sorted(self.home, key=lambda x: x.data()["created_at"]) self.post = posts[n-1] @@ -349,8 +350,12 @@ or get it from the cache.""" print("Retrieved post from the cache.") else: print("Loading...") - self.post = diaspy.models.Post(connection = self.connection, id = id) - self.post_cache[id] = self.post + try: + self.post = diaspy.models.Post(connection = self.connection, id = id) + self.post_cache[id] = self.post + except diaspy.errors.PostError: + print("Cannot load this post.") + return None return self.post def do_reload(self, line): -- 2.25.1