From 99adf9b1b8a02d9ca8d6dee87f51dc952ab76318 Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 9 Aug 2021 23:13:50 +0200 Subject: mastodon-http--triage - messages errors rather than response buffer --- lisp/mastodon-http.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index e8fd4d3..94aa85d 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -67,15 +67,28 @@ (string-match "[0-9][0-9][0-9]" status-line) (match-string 0 status-line))) +;; (defun mastodon-http--triage (response success) +;; "Determine if RESPONSE was successful. Call SUCCESS if successful. + +;; Open RESPONSE buffer if unsuccessful." +;; (let ((status (with-current-buffer response +;; (mastodon-http--status)))) +;; (if (string-prefix-p "2" status) +;; (funcall success) +;; (switch-to-buffer response)))) + (defun mastodon-http--triage (response success) "Determine if RESPONSE was successful. Call SUCCESS if successful. -Open RESPONSE buffer if unsuccessful." +Message status and JSON error from RESPONSE if unsuccessful." (let ((status (with-current-buffer response (mastodon-http--status)))) (if (string-prefix-p "2" status) (funcall success) - (switch-to-buffer response)))) + (progn + (switch-to-buffer response) + (let ((json-response (mastodon-http--process-json))) + (message "Error %s: %s" status (cdr (assoc 'error json-response)))))))) (defun mastodon-http--post (url args headers &optional unauthenticed-p) "POST synchronously to URL with ARGS and HEADERS. -- cgit v1.2.3