summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-05-24 17:22:43 +0200
committerLudovic Courtès <ludo@gnu.org>2015-05-24 17:27:36 +0200
commit9b14107f2d686a5554bc174856f345d8daaff22d (patch)
treef54467e8579e0cbf3bac0e90665feb4b09d5508f
parentf245b03debfa05fa692e95769a9b7116200bf191 (diff)
ui: Add 'copy-file' replacement with better error reporting.
* guix/ui.scm (copy-file): New procedure.
-rw-r--r--guix/ui.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm
index 9bab7c51dd..372733c243 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)