From 405ad09845e152990df09a3f2f1ed52e178df2c0 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 28 Jan 2023 16:27:24 +0100 Subject: list-favouriters/boosters: handle null response --- lisp/mastodon-toot.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 35fe457..3f19a0d 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -441,18 +441,21 @@ With FAVOURITE, list favouriters, else list boosters." (url (mastodon-http--api (format "statuses/%s/%s" base-toot endpoint))) (params '(("limit" . "80"))) - (json (mastodon-http--get-json url params)) - (handles (mapcar (lambda (x) (alist-get 'acct x)) json)) - (type-string (if favourite "Favouriters" "Boosters"))) - (if (not handles) - (error "Looks like this toot has no %s" type-string) - (let ((choice - (completing-read - (format "%s (enter to view profile): " type-string) - handles - nil - t))) - (mastodon-profile--show-user choice))))) + (json (mastodon-http--get-json url params))) + (if (eq (caar json) 'error) + (error "%s (Status does not exist or is private)" + (alist-get 'error json)) + (let ((handles (mapcar (lambda (x) (alist-get 'acct x)) json)) + (type-string (if favourite "Favouriters" "Boosters"))) + (if (not handles) + (error "Looks like this toot has no %s" type-string) + (let ((choice + (completing-read + (format "%s (enter to view profile): " type-string) + handles + nil + t))) + (mastodon-profile--show-user choice))))))) (defun mastodon-toot--copy-toot-url () "Copy URL of toot at point. -- cgit v1.2.3