summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-02-02 15:53:55 +0100
committerLudovic Courtès <ludo@gnu.org>2022-02-02 17:58:20 +0100
commit31ca569ca511b94786c8a8019a8d6fbaeac005f1 (patch)
tree9f8709cb144e7395e267f40b851d048deb10e7f8
parent2178692c931a09dc05e0a42671dc983fbd2e50d2 (diff)
downloadguix-31ca569ca511b94786c8a8019a8d6fbaeac005f1.tar.gz
import: pypi: Use 'with-error-handling'.
* guix/scripts/import/pypi.scm (guix-import-pypi): Wrap body in
'with-error-handling'.
-rw-r--r--guix/scripts/import/pypi.scm37
1 files changed, 19 insertions, 18 deletions
diff --git a/guix/scripts/import/pypi.scm b/guix/scripts/import/pypi.scm
index a52cd95c93..b9b12ee43a 100644
--- a/guix/scripts/import/pypi.scm
+++ b/guix/scripts/import/pypi.scm
@@ -79,27 +79,28 @@ Import and convert the PyPI package for PACKAGE-NAME.\n"))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
-                            (('argument . value)
-                             value)
-                            (_ #f))
+                             (('argument . value)
+                              value)
+                             (_ #f))
                            (reverse opts))))
     (match args
       ((spec)
-       (let ((name version (package-name->name+version spec)))
-         (if (assoc-ref opts 'recursive)
-             ;; Recursive import
-             (map (match-lambda
-                    ((and ('package ('name name) . rest) pkg)
-                     `(define-public ,(string->symbol name)
-                        ,pkg))
-                    (_ #f))
-                  (pypi-recursive-import name version))
-             ;; Single import
-             (let ((sexp (pypi->guix-package name #:version version)))
-               (unless sexp
-                 (leave (G_ "failed to download meta-data for package '~a'~%")
-                        name))
-               sexp))))
+       (with-error-handling
+         (let ((name version (package-name->name+version spec)))
+           (if (assoc-ref opts 'recursive)
+               ;; Recursive import
+               (map (match-lambda
+                      ((and ('package ('name name) . rest) pkg)
+                       `(define-public ,(string->symbol name)
+                          ,pkg))
+                      (_ #f))
+                    (pypi-recursive-import name version))
+               ;; Single import
+               (let ((sexp (pypi->guix-package name #:version version)))
+                 (unless sexp
+                   (leave (G_ "failed to download meta-data for package '~a'~%")
+                          name))
+                 sexp)))))
       (()
        (leave (G_ "too few arguments~%")))
       ((many ...)