summaryrefslogtreecommitdiff
path: root/guix/ui.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-03-09 23:37:12 +0100
committerLudovic Courtès <ludo@gnu.org>2016-03-09 23:47:49 +0100
commitbec7f352145699c929425397957c52a3829623cf (patch)
tree884f0e5875adf82562c8f7a5ce2793f69e564adc /guix/ui.scm
parent8bcdc23fd0476ed56a91cb8a4c0a115fd7194e2d (diff)
downloadguix-patches-bec7f352145699c929425397957c52a3829623cf.tar
guix-patches-bec7f352145699c929425397957c52a3829623cf.tar.gz
ui: Do not call 'port-filename' on closed file ports.
* guix/ui.scm (call-with-error-handling)[port-filename*]: New procedure. Use it in the 'nar-error?' case.
Diffstat (limited to 'guix/ui.scm')
-rw-r--r--guix/ui.scm10
1 files changed, 8 insertions, 2 deletions
diff --git a/guix/ui.scm b/guix/ui.scm
index a3ec6834b6..7b7bee0ac8 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -410,6 +410,12 @@ interpreted."
(define (call-with-error-handling thunk)
"Call THUNK within a user-friendly error handler."
+ (define (port-filename* port)
+ ;; 'port-filename' returns #f for non-file ports, but it raises an
+ ;; exception for file ports that are closed. Work around that.
+ (and (not (port-closed? port))
+ (port-filename port)))
+
(guard (c ((package-input-error? c)
(let* ((package (package-error-package c))
(input (package-error-invalid-input c))
@@ -440,9 +446,9 @@ interpreted."
(port (nar-error-port c)))
(if file
(leave (_ "corrupt input while restoring '~a' from ~s~%")
- file (or (port-filename port) port))
+ file (or (port-filename* port) port))
(leave (_ "corrupt input while restoring archive from ~s~%")
- (or (port-filename port) port)))))
+ (or (port-filename* port) port)))))
((nix-connection-error? c)
(leave (_ "failed to connect to `~a': ~a~%")
(nix-connection-error-file c)