diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-01-27 23:02:48 +0100 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-01-28 09:09:28 +0100 |
commit | dc33073b2da99375e1b77580f15575db78a405ac (patch) | |
tree | e52f78fa39cee1385c697c331578eb8ac9c787f3 /lisp/mastodon-http.el | |
parent | 5faed06cc47238ffea43145204a90a2bd13b6bf2 (diff) |
http--process-response: display response as error if not json
still need to handle possible html.
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r-- | lisp/mastodon-http.el | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 3cc5511..88bc9c6 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -204,8 +204,18 @@ Callback to `mastodon-http--get-response-async', usually (buffer-substring-no-properties (point) (point-max)) 'utf-8))) (kill-buffer) - (unless (or (string-empty-p json-string) (null json-string)) - `(,(json-read-from-string json-string) . ,headers))))) + ;; (unless (or (string-empty-p json-string) (null json-string)) + (cond ((or (string-empty-p json-string) (null json-string)) + nil) + ;; if we don't have json, maybe we have a plain string error + ;; message (misskey works like this for instance, but there are + ;; probably less dunce ways to do this): + ;; FIXME: friendica at least sends plain html if endpoint not found. + ((not (or (string-prefix-p "\n{" json-string) + (string-prefix-p "\n[" json-string))) + (error "%s" json-string)) + (t + `(,(json-read-from-string json-string) . ,headers)))))) (defun mastodon-http--process-headers () "Return an alist of http response headers." |