diff options
author | mousebot <mousebot@riseup.net> | 2021-08-09 23:13:50 +0200 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-08-09 23:13:50 +0200 |
commit | 99adf9b1b8a02d9ca8d6dee87f51dc952ab76318 (patch) | |
tree | 5609778e2a70d765f0d278a140698a4453d9a2d3 /lisp/mastodon-http.el | |
parent | 8ffa61e0d46c5a263d5afeaa95069608148405a3 (diff) |
mastodon-http--triage - messages errors rather than response buffer
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r-- | lisp/mastodon-http.el | 17 |
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. |