Skip to content

Commit 67bbcc7

Browse files
committed
Logging
1 parent 52340f7 commit 67bbcc7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/notifications.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import discord_logging
2+
import prawcore.exceptions
23

34
log = discord_logging.get_logger()
45

@@ -44,7 +45,13 @@ def send_queued_notifications(reddit, database):
4445

4546
body_bldr = utils.get_footer(notification.render_notification(submissions))
4647
subject_bldr = notification.render_subject()
47-
result = reddit.send_message(notification.subscription.subscriber.name, ''.join(subject_bldr), ''.join(body_bldr))
48+
try:
49+
result = reddit.send_message(notification.subscription.subscriber.name, ''.join(subject_bldr), ''.join(body_bldr))
50+
except prawcore.exceptions.ServerError:
51+
log.warning(f"Failure sending notification message to u/{notification.subscription.subscriber.name}")
52+
log.warning(f"Subject: {''.join(subject_bldr)}")
53+
log.warning(f"Body: {''.join(body_bldr)}")
54+
raise
4855
notification.submission.messages_sent += 1
4956
if result != ReturnType.SUCCESS:
5057
counters.api_responses.labels(call='notif', type=result.name.lower()).inc()

0 commit comments

Comments
 (0)