jupyter-available-kernelspecs: Handle parsing kernelspecs better

Raise an error when `jupyter kernelspec list --json` doesn't return
valid JSON.
This commit is contained in:
Nathaniel Nicandro 2023-06-08 09:19:17 -05:00
parent 11ace8c805
commit e548c6cdbb

View file

@ -76,9 +76,20 @@ REFRESH."
(or (and (not refresh) (gethash host jupyter--kernelspecs))
(let ((specs
(plist-get
(jupyter-read-plist-from-string
(or (jupyter-command "kernelspec" "list" "--json" "--log-level" "ERROR")
(error "Can't obtain kernelspecs from jupyter shell command")))
(let ((json (or (jupyter-command "kernelspec" "list"
"--json" "--log-level" "ERROR")
(error "\
Can't obtain kernelspecs from jupyter shell command"))))
(condition-case nil
(jupyter-read-plist-from-string json)
(error
(error "\
Jupyter kernelspecs couldn't be parsed from
jupyter kernelspec list --json
To investiagate further, run that command in a shell and examine
why it isn't returning valid JSON."))))
:kernelspecs)))
(puthash
host