summaryrefslogtreecommitdiff
path: root/postgresqleu/util
diff options
context:
space:
mode:
authorMagnus Hagander2024-06-19 14:51:47 +0000
committerMagnus Hagander2024-06-19 14:51:47 +0000
commit57039dbe26f3b5abba8318262b78e5f6c9ca812e (patch)
tree8e5313ab45a33f47ea4bf789537b69093687b731 /postgresqleu/util
parentb45cd0aefe6bbae30957143803b19e2f508d427e (diff)
Trap exceptions when posting to social media
The providers themselves would catch some exceptions and turn them into proper error messages, but for the cases where they don't, we want the loop in the sender to do so for us and just log the exception message.
Diffstat (limited to 'postgresqleu/util')
-rw-r--r--postgresqleu/util/messaging/sender.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/postgresqleu/util/messaging/sender.py b/postgresqleu/util/messaging/sender.py
index 3301b15d..73dc3701 100644
--- a/postgresqleu/util/messaging/sender.py
+++ b/postgresqleu/util/messaging/sender.py
@@ -126,14 +126,18 @@ FOR UPDATE OF confreg_conferencetweetqueue"""))
contents = t.contents[str(p.id)] if isinstance(t.contents, dict) else t.contents
# Don't try to post it if it's empty
if contents:
- (id, errmsg) = impl.post(
- truncate_shortened_post(
- contents,
- impl.max_post_length
- ),
- t.image,
- t.replytotweetid,
- )
+ try:
+ (id, errmsg) = impl.post(
+ truncate_shortened_post(
+ contents,
+ impl.max_post_length
+ ),
+ t.image,
+ t.replytotweetid,
+ )
+ except Exception as e:
+ errmsg = "Exception: {}".format(e)
+ id = None
if id:
t.remainingtosend.remove(p)