guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/04: ui: Add 'copy-file' replacement with better error reporting.


From: Ludovic Courtès
Subject: 03/04: ui: Add 'copy-file' replacement with better error reporting.
Date: Sun, 24 May 2015 15:37:06 +0000

civodul pushed a commit to branch master
in repository guix.

commit 9b14107f2d686a5554bc174856f345d8daaff22d
Author: Ludovic Courtès <address@hidden>
Date:   Sun May 24 17:22:43 2015 +0200

    ui: Add 'copy-file' replacement with better error reporting.
    
    * guix/ui.scm (copy-file): New procedure.
---
 guix/ui.scm |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 9bab7c5..372733c 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -246,6 +246,23 @@ General help using GNU software: 
<http://www.gnu.org/gethelp/>"))
                  (append args (list link))
                  errno))))))
 
+(set! copy-file
+  ;; Note: here we use 'set!', not #:replace, because UIs typically use
+  ;; 'copy-recursively', which doesn't use (guix ui).
+  (let ((real-copy-file (@ (guile) copy-file)))
+    (lambda (source target)
+      "This is a 'copy-file' replacement that provides proper error reporting."
+      (catch 'system-error
+        (lambda ()
+          (real-copy-file source target))
+        (lambda (key proc fmt args errno)
+          ;; Augment the FMT and ARGS with information about TARGET (this
+          ;; information is missing as of Guile 2.0.11, making the exception
+          ;; uninformative.)
+          (apply throw key proc "~A: ~S"
+                 (list (strerror (car errno)) target)
+                 (list errno)))))))
+
 (define (string->number* str)
   "Like `string->number', but error out with an error message on failure."
   (or (string->number str)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]