branch: elpa/mastodon
commit b92395439a7c53ee786ea8545024221d6c4cb3a5
Author: marty hiatt <martianhia...@disroot.org>
Commit: marty hiatt <martianhia...@disroot.org>

    client: fetch -- handle instance response error
---
 lisp/mastodon-client.el | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el
index c548785a12..1ad6d2bed7 100644
--- a/lisp/mastodon-client.el
+++ b/lisp/mastodon-client.el
@@ -82,12 +82,16 @@
       (with-current-buffer buf
         (goto-char (point-min))
         (re-search-forward "^$" nil 'move)
-        (let ((json-object-type 'plist)
-              (json-key-type 'keyword)
-              (json-array-type 'vector)
-              (json-string
-               (buffer-substring-no-properties (point) (point-max))))
-          (json-read-from-string json-string))))))
+        (let* ((json-object-type 'plist)
+               (json-key-type 'keyword)
+               (json-array-type 'vector)
+               (json-string
+                (buffer-substring-no-properties (point) (point-max)))
+               (parsed
+                (json-read-from-string json-string)))
+          (if (eq :error (car parsed))
+              (error "Error: %s" (cadr parsed))
+            parsed))))))
 
 (defun mastodon-client--token-file ()
   "Return `mastodon-client--token-file'."

Reply via email to