guix-commits
[Top][All Lists]
Advanced

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

03/05: scripts: import: go: Wrap body in 'with-error-handling'.


From: guix-commits
Subject: 03/05: scripts: import: go: Wrap body in 'with-error-handling'.
Date: Sun, 9 Jan 2022 17:25:54 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit d1e3c96759407a4d7db8f5975b0e78941a0e64c4
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Jan 9 22:34:01 2022 +0100

    scripts: import: go: Wrap body in 'with-error-handling'.
    
    This ensures proper error reporting and an exception reaches the top
    level.
    
    * guix/scripts/import/go.scm (guix-import-go): Wrap body in
    'with-error-handling'.
---
 guix/scripts/import/go.scm | 69 +++++++++++++++++++++++-----------------------
 1 file changed, 35 insertions(+), 34 deletions(-)

diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm
index f5cfea8683..f1970d3543 100644
--- a/guix/scripts/import/go.scm
+++ b/guix/scripts/import/go.scm
@@ -87,37 +87,38 @@ that are not yet in Guix"))
     (parse-command-line args %options (list %default-options)
                         #:build-options? #f))
 
-  (let* ((opts (parse-options))
-         (args (filter-map (match-lambda
-                             (('argument . value)
-                              value)
-                             (_ #f))
-                           (reverse opts)))
-         ;; Append the full version to the package symbol name when using
-         ;; pinned versions.
-         (package->definition* (if (assoc-ref opts 'pin-versions?)
-                                   (cut package->definition <> 'full)
-                                   package->definition)))
-    (match args
-      ((spec)                         ;e.g., github.com/golang/protobuf@v1.3.1
-       (receive (name version)
-           (package-name->name+version spec)
-         (let ((arguments (list name
-                                #:goproxy (assoc-ref opts 'goproxy)
-                                #:version version
-                                #:pin-versions?
-                                (assoc-ref opts 'pin-versions?))))
-           (if (assoc-ref opts 'recursive)
-               ;; Recursive import.
-               (map package->definition*
-                    (apply go-module-recursive-import arguments))
-               ;; Single import.
-               (let ((sexp (apply go-module->guix-package* arguments)))
-                 (unless sexp
-                   (leave (G_ "failed to download meta-data for module 
'~a'.~%")
-                          name))
-                 (package->definition* sexp))))))
-      (()
-       (leave (G_ "too few arguments~%")))
-      ((many ...)
-       (leave (G_ "too many arguments~%"))))))
+  (with-error-handling
+    (let* ((opts (parse-options))
+           (args (filter-map (match-lambda
+                               (('argument . value)
+                                value)
+                               (_ #f))
+                             (reverse opts)))
+           ;; Append the full version to the package symbol name when using
+           ;; pinned versions.
+           (package->definition* (if (assoc-ref opts 'pin-versions?)
+                                     (cut package->definition <> 'full)
+                                     package->definition)))
+      (match args
+        ((spec)                       ;e.g., github.com/golang/protobuf@v1.3.1
+         (receive (name version)
+             (package-name->name+version spec)
+           (let ((arguments (list name
+                                  #:goproxy (assoc-ref opts 'goproxy)
+                                  #:version version
+                                  #:pin-versions?
+                                  (assoc-ref opts 'pin-versions?))))
+             (if (assoc-ref opts 'recursive)
+                 ;; Recursive import.
+                 (map package->definition*
+                      (apply go-module-recursive-import arguments))
+                 ;; Single import.
+                 (let ((sexp (apply go-module->guix-package* arguments)))
+                   (unless sexp
+                     (leave (G_ "failed to download meta-data for module 
'~a'.~%")
+                            name))
+                   (package->definition* sexp))))))
+        (()
+         (leave (G_ "too few arguments~%")))
+        ((many ...)
+         (leave (G_ "too many arguments~%")))))))



reply via email to

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