From 60ac9773d29a0d761d8be42878b471c755a59779 Mon Sep 17 00:00:00 2001 From: Holger Dürer Date: Wed, 7 Jun 2017 18:29:10 +0100 Subject: Catch any errors thrown during url-retrieve. On Emacs24 I've been able to reliably fail url fetching which exposed issues in loading a timeline (it aborts the loading). This catches any errors, marking the image load as failed so that we won't retry (retries are a TODO item I guess) and then succeeds the function so the rest of the timeline loading can proceed. --- lisp/mastodon-media.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index 0a4c3de..50f79dd 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -170,9 +170,18 @@ MEDIA-TYPE is a symbol and either 'avatar or 'media-link." `(:height ,mastodon-media--avatar-height)) ((eq media-type 'media-link) `(:max-height ,mastodon-media--preview-max-height)))))) - (url-retrieve url - #'mastodon-media--process-image-response - (list (copy-marker start) image-options region-length)))) + (let ((buffer (current-buffer)) + (marker (copy-marker start))) + (condition-case nil + ;; catch any errors in url-retrieve so as to not abort + ;; whatever called us + (url-retrieve url + #'mastodon-media--process-image-response + (list marker image-options region-length)) + (error (with-current-buffer buffer + ;; TODO: Consider adding retries + (put-text-property marker (+ marker region-length) 'media-state 'loading-failed) + :loading-failed)))))) (defun mastodon-media--select-next-media-line () "Find coordinates of the next media to load. -- cgit v1.2.3