aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-08-09 23:13:50 +0200
committermousebot <mousebot@riseup.net>2021-08-09 23:13:50 +0200
commit99adf9b1b8a02d9ca8d6dee87f51dc952ab76318 (patch)
tree5609778e2a70d765f0d278a140698a4453d9a2d3 /lisp
parent8ffa61e0d46c5a263d5afeaa95069608148405a3 (diff)
mastodon-http--triage - messages errors rather than response buffer
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-http.el17
1 files changed, 15 insertions, 2 deletions
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.