aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-21 18:25:35 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-21 18:25:35 +0100
commit62e18cd138f322b0e1b8ce1139b4d129f6929b9a (patch)
treeabb1e9d10e936dddf5906d3c709675e919f4f7fd /lisp
parentbf7cc6fd0cde8b3caba850bad7c9b217bef481a7 (diff)
no switch to response buffer on non-200 http response
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-http.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index 6e7bfb3..37770ef 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -88,11 +88,13 @@ Message status and JSON error from RESPONSE if unsuccessful."
(mastodon-http--status))))
(if (string-prefix-p "2" status)
(funcall success)
- (switch-to-buffer response)
- ;; 404 returns http response not JSON:
+ ;; don't switch to buffer, just with-current-buffer the response:
+ ;; (switch-to-buffer response)
+ ;; 404 sometimes returns http response so --process-json fails:
(if (string-prefix-p "404" status)
(message "Error %s: page not found" status)
- (let ((json-response (mastodon-http--process-json)))
+ (let ((json-response (with-current-buffer response
+ (mastodon-http--process-json))))
(message "Error %s: %s" status (alist-get 'error json-response)))))))
(defun mastodon-http--read-file-as-string (filename)