summaryrefslogtreecommitdiff
path: root/guix/scripts/download.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/scripts/download.scm')
-rw-r--r--guix/scripts/download.scm47
1 files changed, 24 insertions, 23 deletions
diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm
index 3dc227fdcd..3f989a3494 100644
--- a/guix/scripts/download.scm
+++ b/guix/scripts/download.scm
@@ -110,26 +110,27 @@ and the hash of its contents.\n"))
(alist-cons 'argument arg result))
%default-options))
- (let* ((opts (parse-options))
- (store (open-connection))
- (arg (assq-ref opts 'argument))
- (uri (or (string->uri arg)
- (leave (_ "guix-download: ~a: failed to parse URI~%")
- arg)))
- (path (case (uri-scheme uri)
- ((file)
- (add-to-store store (basename (uri-path uri))
- #f "sha256" (uri-path uri)))
- (else
- (fetch-and-store store
- (cut url-fetch arg <>
- #:mirrors %mirrors)
- (basename (uri-path uri))))))
- (hash (call-with-input-file
- (or path
- (leave (_ "guix-download: ~a: download failed~%")
- arg))
- (compose sha256 get-bytevector-all)))
- (fmt (assq-ref opts 'format)))
- (format #t "~a~%~a~%" path (fmt hash))
- #t))
+ (with-error-handling
+ (let* ((opts (parse-options))
+ (store (open-connection))
+ (arg (assq-ref opts 'argument))
+ (uri (or (string->uri arg)
+ (leave (_ "guix-download: ~a: failed to parse URI~%")
+ arg)))
+ (path (case (uri-scheme uri)
+ ((file)
+ (add-to-store store (basename (uri-path uri))
+ #f "sha256" (uri-path uri)))
+ (else
+ (fetch-and-store store
+ (cut url-fetch arg <>
+ #:mirrors %mirrors)
+ (basename (uri-path uri))))))
+ (hash (call-with-input-file
+ (or path
+ (leave (_ "guix-download: ~a: download failed~%")
+ arg))
+ (compose sha256 get-bytevector-all)))
+ (fmt (assq-ref opts 'format)))
+ (format #t "~a~%~a~%" path (fmt hash))
+ #t)))