Commit 943c9aff authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

kernel: Gracefully handle package-not-found errors.

* guix-jupyter-kernel.scm (reply-execute-request): Wrap
'create-environment' calls in 'guard' and send a proper HTML reply upon
'package-not-found-error?' and 'output-not-found-error?'.
* guix/jupyter/environment.scm (&environment-error)
(&package-not-found-error, &output-not-found-error): Export accessors.
parent 72d838cd
......@@ -482,21 +482,41 @@ stripped."
(pub-busy kernel message)
(match (string-tokenize line)
((";;guix" "environment" name "<-" specs ...)
(let ((state (ensure-proxy-state-inferior state)))
(match (lookup-proxied name state)
(#f
(create-environment name specs state
#:kernel kernel
#:message message))
((? kernel? proxy)
(format/log "terminating existing '~a' environment~%"
name)
(unmonitor-client proxy)
(terminate-proxied-kernel proxy)
(create-environment name specs
(unregister-proxied name state)
#:kernel kernel
#:message message)))))
(guard (c ((package-not-found-error? c)
(let ((package (package-not-found-error-name c)))
(reply-html kernel message
(sxml->html-string
`(div (@ (class "ansi-red-fg"))
"Package " (code ,package)
" not found."))
count))
state)
((output-not-found-error? c)
(let ((output (output-not-found-error-output c))
(package (output-not-found-error-package c)))
(reply-html kernel message
(sxml->html-string
`(div (@ (class "ansi-red-fg"))
"Output " (code ,output)
" of package " (code ,package)
" not found."))
count)
state)))
(let ((state (ensure-proxy-state-inferior state)))
(match (lookup-proxied name state)
(#f
(create-environment name specs state
#:kernel kernel
#:message message))
((? kernel? proxy)
(format/log "terminating existing '~a' environment~%"
name)
(unmonitor-client proxy)
(terminate-proxied-kernel proxy)
(create-environment name specs
(unregister-proxied name state)
#:kernel kernel
#:message message))))))
((";;guix" "environment" name)
(match (lookup-proxied name state)
(#f
......
......@@ -30,6 +30,14 @@
#:export (open-default-inferior
specifications->manifest
environment-error?
package-not-found-error?
package-not-found-error-name
package-not-found-error-version
output-not-found-error?
output-not-found-error-output
output-not-found-error-package
channel-commit-hyperlink))
(define %user-profile
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment