aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-http.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mastodon-http.el')
-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.