diff options
author | mousebot <mousebot@riseup.net> | 2021-10-29 11:58:53 +0200 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-10-29 11:58:53 +0200 |
commit | 39a54a6aaf1a6f043bfe8769ef0c3484de917e7c (patch) | |
tree | 66a65a3a7e080605959260afd3e8b7f5b7e285b5 /lisp/mastodon-http.el | |
parent | 4c7c6f4f3cb832cecc67da23e4567e11a236adf7 (diff) |
hopefully improve attachment upload error handling
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r-- | lisp/mastodon-http.el | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 4f4cc3f..b5437a3 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -285,15 +285,21 @@ The upload is asynchronous. On succeeding, `mastodon-toot--media-attachment-ids' (mastodon-toot--update-status-fields))))) :error (cl-function (lambda (&key error-thrown &allow-other-keys) - (message "%s" (car (last error-thrown))) - (message "%s" (type-of (car (last error-thrown)))) - (cond ((= (car (last error-thrown)) 401) - (message "Got error: %s Unauthorized: The access token is invalid" error-thrown)) - ((= (car (last error-thrown)) 422) - (message "Got error: %s Unprocessable entity: file or file type is unsupported or invalid" error-thrown)) - (t - (message "Got error: %s Shit went south" - error-thrown)))))))) + (cond + ;; handle curl errors first (eg 26, can't read file/path) + ;; because the '=' test below fails for them + ;; they have the form (error . error message 24) + ((not (proper-list-p error-thrown)) ; not dotted list + (message "Got error: %s. Shit went south." (cdr error-thrown))) + ;; handle mastodon api errors + ;; they have the form (error http 401) + ((= (car (last error-thrown)) 401) + (message "Got error: %s Unauthorized: The access token is invalid" error-thrown)) + ((= (car (last error-thrown)) 422) + (message "Got error: %s Unprocessable entity: file or file type is unsupported or invalid" error-thrown)) + (t + (message "Got error: %s Shit went south" + error-thrown)))))))) (provide 'mastodon-http) ;;; mastodon-http.el ends here |