summaryrefslogtreecommitdiff
path: root/guix/store.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-03-07 19:29:12 +0100
committerLudovic Courtès <ludo@gnu.org>2013-03-07 19:44:14 +0100
commitef86c39f27b0d1c21435ea54cba5fb247e341537 (patch)
treeb0e93558496a06d6e0ee036f75423a083b8787b2 /guix/store.scm
parent1fb78cb2c36a6b0d7a3ecf1f7150c4d99b01c1a9 (diff)
downloadguix-patches-ef86c39f27b0d1c21435ea54cba5fb247e341537.tar
guix-patches-ef86c39f27b0d1c21435ea54cba5fb247e341537.tar.gz
ui: Gracefully report failures to connect to the daemon.
* guix/store.scm (&nix-connection-error): New condition type. (open-connection): Translate `system-error' during the `connect' call into `&nix-connection-error'. * guix/ui.scm (call-with-error-handling): Add case for `nix-connection-error?'. * guix/scripts/package.scm (guix-package): Move `open-connection' call within `with-error-handling'. * guix/scripts/pull.scm (guix-pull): Likewise. * guix/scripts/download.scm (guix-download): Move body within `with-error-handling'.
Diffstat (limited to 'guix/store.scm')
-rw-r--r--guix/store.scm18
1 files changed, 17 insertions, 1 deletions
diff --git a/guix/store.scm b/guix/store.scm
index 80b36daf93..eaf1cd544f 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -39,6 +39,9 @@
nix-server-socket
&nix-error nix-error?
+ &nix-connection-error nix-connection-error?
+ nix-connection-error-file
+ nix-connection-error-code
&nix-protocol-error nix-protocol-error?
nix-protocol-error-message
nix-protocol-error-status
@@ -373,6 +376,11 @@
(define-condition-type &nix-error &error
nix-error?)
+(define-condition-type &nix-connection-error &nix-error
+ nix-connection-error?
+ (file nix-connection-error-file)
+ (errno nix-connection-error-code))
+
(define-condition-type &nix-protocol-error &nix-error
nix-protocol-error?
(message nix-protocol-error-message)
@@ -392,7 +400,15 @@ operate, should the disk become full. Return a server object."
;; Enlarge the receive buffer.
(setsockopt s SOL_SOCKET SO_RCVBUF (* 12 1024))
- (connect s a)
+ (catch 'system-error
+ (cut connect s a)
+ (lambda args
+ ;; Translate the error to something user-friendly.
+ (let ((errno (system-error-errno args)))
+ (raise (condition (&nix-connection-error
+ (file file)
+ (errno errno)))))))
+
(write-int %worker-magic-1 s)
(let ((r (read-int s)))
(and (eqv? r %worker-magic-2)