mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 07:41:37 -05:00
Fix error handling in TRAMP functions for Emacs >= 27
TRAMP sets its own value of `signal-hook-function` which interferes with `signal` data when handling errors in `condition-case` so unbind `signal-hook-function` until we have a chance to look at `signal` data. * jupyter-server.el (jupyter-kernel-alive-p): Use `nth` * jupyter-tramp.el (jupyter-tramp--get-directory-or-file-model) (jupyter-tramp-delete-directory): Unbind `signal-hook-function`.
This commit is contained in:
parent
aee4d39449
commit
8fd5d8d95e
2 changed files with 17 additions and 8 deletions
|
@ -143,7 +143,7 @@ Access should be done through `jupyter-available-kernelspecs'.")))
|
|||
(jupyter-api-get-kernel (oref kernel server) (oref kernel id))
|
||||
(file-error nil) ; Non-existent server
|
||||
(jupyter-api-http-error
|
||||
(unless (= (cadr err) 404) ; Not Found
|
||||
(unless (= (nth 1 err) 404) ; Not Found
|
||||
(signal (car err) (cdr err)))))))
|
||||
|
||||
(cl-defmethod jupyter-start-kernel ((kernel jupyter-server-kernel) &rest _ignore)
|
||||
|
|
|
@ -330,7 +330,10 @@ fails."
|
|||
(jupyter-tramp-get-file-model (file-name-directory file)))
|
||||
(t
|
||||
(condition-case err
|
||||
(jupyter-api-get-file-model jupyter-current-server localname)
|
||||
;; Unset `signal-hook-function' so that TRAMP in Emacs >= 27 does not
|
||||
;; mess with the signal data until we have a chance to look at it.
|
||||
(let (signal-hook-function)
|
||||
(jupyter-api-get-file-model jupyter-current-server localname))
|
||||
(jupyter-api-http-error
|
||||
(cl-destructuring-bind (_ code msg) err
|
||||
(if (and (eq code 404)
|
||||
|
@ -345,7 +348,8 @@ fails."
|
|||
(directory-file-name file))
|
||||
'no-content)
|
||||
:writable))
|
||||
(signal (car err) (cdr err)))))))))
|
||||
(signal (car err) (cdr err)))))
|
||||
(error (signal (car err) (cdr err)))))))
|
||||
|
||||
(defun jupyter-tramp--get-file-model (file localname no-content)
|
||||
(let* ((path (jupyter-api-content-path localname))
|
||||
|
@ -520,13 +524,18 @@ See `jupyter-tramp-get-file-model' for details on what a file model is."
|
|||
;; empty, manually delete all files below and then try again.
|
||||
(condition-case err
|
||||
(prog1 t
|
||||
(jupyter-api-delete-file
|
||||
jupyter-current-server
|
||||
directory))
|
||||
;; Unset `signal-hook-function' so that TRAMP in Emacs >= 27
|
||||
;; does not mess with the signal data until we have a chance
|
||||
;; to look at it.
|
||||
(let (signal-hook-function)
|
||||
(jupyter-api-delete-file
|
||||
jupyter-current-server
|
||||
directory)))
|
||||
(jupyter-api-http-error
|
||||
(unless (and (= (cadr err) 400)
|
||||
(unless (and (= (nth 1 err) 400)
|
||||
(string-match-p "not empty" (caddr err)))
|
||||
(signal (car err) (cdr err)))))))
|
||||
(signal (car err) (cdr err))))
|
||||
(error (signal (car err) (cdr err))))))
|
||||
(unless deleted
|
||||
;; Recursive delete, we need to do this manually since we can get a 400
|
||||
;; error on Windows when deleting to trash and also in general when not
|
||||
|
|
Loading…
Add table
Reference in a new issue