From ddb46468de88183e16077cdee85d80724c2e2804 Mon Sep 17 00:00:00 2001 From: saturn Date: Mon, 4 Sep 2023 15:52:29 -0500 Subject: [PATCH] Gracefully handle errors when a crosspost can't be retrieved. --- src/backend.lisp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/backend.lisp b/src/backend.lisp index 1ec70195..84915eac 100644 --- a/src/backend.lisp +++ b/src/backend.lisp @@ -766,18 +766,23 @@ is-crosspost foreign-post-id)) post) (:otherwise - (let* ((*current-site* (find-site (backend-magnum-crosspost-site backend))) - (*current-backend* (site-backend *current-site*)) - (*retrieve-crosspost* nil) - (foreign-post (get-post-body foreign-post-id :revalidate revalidate :force-revalidate force-revalidate)) - (foreign-post-body (cdr (assoc :html-body foreign-post)))) - (declare (special *retrieve-crosspost*)) - (if foreign-post-body - (list-cond* - ((not hosted-here) :html-body foreign-post-body) - (t :foreign-post foreign-post) - post) - post)))))))) + (block nil + (handler-bind ((error (lambda (condition) + (declare (ignore condition)) + (when hosted-here + (return post))))) + (let* ((*current-site* (find-site (backend-magnum-crosspost-site backend))) + (*current-backend* (site-backend *current-site*)) + (*retrieve-crosspost* nil) + (foreign-post (get-post-body foreign-post-id :revalidate revalidate :force-revalidate force-revalidate)) + (foreign-post-body (cdr (assoc :html-body foreign-post)))) + (declare (special *retrieve-crosspost*)) + (if foreign-post-body + (list-cond* + ((not hosted-here) :html-body foreign-post-body) + (t :foreign-post foreign-post) + post) + post)))))))))) (defun get-post-comments-list (post-id view &rest rest &key auth-token parent-answer-id fields context) (declare (ignore fields context auth-token)) -- 2.11.4.GIT