dictionary-overlay
dictionary-overlay copied to clipboard
websocket parse json error
Sometimes there will be an error like that:
⛔ Error (websocket): in callback `on-message': could not parse JSON stream: "unable to decode byte 0xc3", "
It won't affect this tool's usability, but it bothers me.
would it help to wrap related code in (with-no-warnings ...) or (ignore-errors ...) somewhere. i haven't look into this issue yet.
or, the error buffer could be managed like elfeed-log buffer: it never shows up, but retrievable by M-x switch-to-buffer RET elfeed-log RET
So, basically i just ignore errors here, finally manage to calm it down. Don't know what the consequences would be, perhaps some words are not saved to the .txt file when err out? Anyway, i'm happy.
(defun websocket-bridge-message-handler (_websocket frame)
"Message handler for given FRAME."
(ignore-errors ;;; <------ What i did.
(let* ((info (json-parse-string (websocket-frame-text frame)))
(info-type (gethash "type" info nil)))
(pcase info-type
("client-app-name"
(set
(intern
(format "websocket-bridge-client-%s"
(gethash "content" info nil)))
_websocket))
("show-message" (message (gethash "content" info nil)))
("eval-code" (eval (read (gethash "content" info nil))))
("fetch-var"
(websocket-send-text _websocket
(json-encode
(eval
(read (gethash "content" info nil))))))))))
Maybe ignoring the json-parse-string
's error is better.
If you ignore too much, it will hide the import message when there is an actual run error.
I will wait to find the real error reason.