diff options
| author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-10-12 20:03:12 +0200 | 
|---|---|---|
| committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-10-12 20:03:12 +0200 | 
| commit | 9aa6a50e095b08bbaf64566a7661ddf0a1880b5d (patch) | |
| tree | 5b30cc7cfec4e99012aeef22c8c73a2669934c8d | |
| parent | 75f07afa41a75bd94d4867350b0e425bf3b2e978 (diff) | |
view instance: if rendering error, display raw json
| -rw-r--r-- | lisp/mastodon-views.el | 47 | 
1 files changed, 28 insertions, 19 deletions
| diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el index 270648c..24fe6d7 100644 --- a/lisp/mastodon-views.el +++ b/lisp/mastodon-views.el @@ -785,25 +785,34 @@ INSTANCE is the instance were are working with."                   (format "*mastodon-instance-%s*" domain))))        (with-mastodon-buffer buf #'special-mode :other-window          (if misskey -            (let ((inhibit-read-only t)) -              (insert (prin1-to-string response)) -              (pp-buffer) -              (goto-char (point-min))) -          (when brief -            (setq response -                  (list (assoc 'uri response) -                        (assoc 'title response) -                        (assoc 'short_description response) -                        (assoc 'email response) -                        (cons 'contact_account -                              (list -                               (assoc 'username -                                      (assoc 'contact_account response)))) -                        (assoc 'rules response) -                        (assoc 'stats response)))) -          (mastodon-views--print-json-keys response) -          (mastodon-tl--set-buffer-spec (buffer-name buf) "instance" nil) -          (goto-char (point-min))))))) +            (mastodon-view--insert-json response) +          (condition-case err +              (progn +                (when brief +                  (setq response +                        (list (assoc 'uri response) +                              (assoc 'title response) +                              (assoc 'short_description response) +                              (assoc 'email response) +                              (cons 'contact_account +                                    (list +                                     (assoc 'username +                                            (assoc 'contact_account response)))) +                              (assoc 'rules response) +                              (assoc 'stats response)))) +                (mastodon-views--print-json-keys response) +                (mastodon-tl--set-buffer-spec (buffer-name buf) "instance" nil) +                (goto-char (point-min))) +            (error ; just insert the raw response: +             (mastodon-views--insert-json response)))))))) + +(defun mastodon-views--insert-json (response) +  "Insert raw JSON RESPONSE in current buffer." +  (let ((inhibit-read-only t)) +    (erase-buffer) +    (insert (prin1-to-string response)) +    (pp-buffer) +    (goto-char (point-min))))  (defun mastodon-views--format-key (el pad)    "Format a key of element EL, a cons, with PAD padding." | 
