From 2354dadddbf235c80f6e8d4d4cb73d087905a275 Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Tue, 10 Mar 2020 18:38:03 -0400 Subject: [PATCH] Catch MastodonNotFoundErrors that were not being caught This will cause a much more sensible error message in the case of trying to reply to or view the thread of deleted messages --- brutaldon/views.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/brutaldon/views.py b/brutaldon/views.py index 5249078..698da19 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -673,9 +673,9 @@ def note(request, next=None, prev=None): @br_login_required def thread(request, id): account, mastodon = get_usercontext(request) - toot = mastodon.status(id) - root = toot try: + toot = mastodon.status(id) + root = toot context = mastodon.status_context(id) if context.ancestors and len(context.ancestors) > 0: root = context.ancestors[0] @@ -1049,8 +1049,11 @@ def safe_get_attachment(toot, index): def reply(request, id): if request.method == "GET": account, mastodon = get_usercontext(request) - toot = mastodon.status(id) - context = mastodon.status_context(id) + try: + toot = mastodon.status(id) + context = mastodon.status_context(id) + except MastodonNotFoundError: + raise Http404(_("Thread not found; the message may have been deleted.")) notifications = _notes_count(account, mastodon) if toot.account.acct != request.session["active_user"].acct: initial_text = "@" + toot.account.acct + " "