GNU bug report logs -
#49196
[PATCH] "guix import go" Improve error handling
Previous Next
Reported by: Sarah Morgensen <iskarian <at> mgsn.dev>
Date: Wed, 23 Jun 2021 20:50:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
* guix/import/go.scm (go-module->guix-package*): Handle errors.
(go-module-recursive-import): Remove 'guard'.
* guix/scripts/import/go.scm (guix-import-go): Adjust.
* tests/go.scm: Adjust.
---
guix/import/go.scm | 43 ++++++++++++++++++++++----------------
guix/scripts/import/go.scm | 6 +++---
tests/go.scm | 2 +-
3 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/guix/import/go.scm b/guix/import/go.scm
index c859098492..c559f02e5b 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2021 Ludovic Courtès <ludo <at> gnu.org>
;;; Copyright © 2021 Xinglu Chen <public <at> yoctocell.xyz>
;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -61,7 +62,7 @@
#:use-module (web response)
#:use-module (web uri)
- #:export (go-module->guix-package
+ #:export (go-module->guix-package*
go-module-recursive-import))
;;; Commentary:
@@ -630,17 +631,9 @@ hint: use one of the following available versions ~a\n"
dependencies+versions
dependencies))))
-(define go-module->guix-package* (memoize go-module->guix-package))
-
-(define* (go-module-recursive-import package-name
- #:key (goproxy "https://proxy.golang.org")
- version
- pin-versions?)
-
- (recursive-import
- package-name
- #:repo->guix-package
- (lambda* (name #:key version repo)
+(define go-module->guix-package*
+ (memoize
+ (lambda args
;; Disable output buffering so that the following warning gets printed
;; consistently.
(setvbuf (current-error-port) 'none)
@@ -648,15 +641,29 @@ hint: use one of the following available versions ~a\n"
(warning (G_ "Failed to import package ~s.
reason: ~s could not be fetched: HTTP error ~a (~s).
This package and its dependencies won't be imported.~%")
- name
+ (match args ((name _ ...) name))
(uri->string (http-get-error-uri c))
(http-get-error-code c)
(http-get-error-reason c))
+ (values #f '()))
+ (else
+ (warning (G_ "Something went wrong with ~s.~%") args)
(values #f '())))
- (receive (package-sexp dependencies)
- (go-module->guix-package* name #:goproxy goproxy
- #:version version
- #:pin-versions? pin-versions?)
- (values package-sexp dependencies))))
+ (apply go-module->guix-package args)))))
+
+(define* (go-module-recursive-import package-name
+ #:key (goproxy "https://proxy.golang.org")
+ version
+ pin-versions?)
+
+ (recursive-import
+ package-name
+ #:repo->guix-package
+ (lambda* (name #:key version repo)
+ (receive (package-sexp dependencies)
+ (go-module->guix-package* name #:goproxy goproxy
+ #:version version
+ #:pin-versions? pin-versions?)
+ (values package-sexp dependencies)))
#:guix-name go-module->guix-package-name
#:version version))
diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm
index 74e8e60cce..071ecdb2ef 100644
--- a/guix/scripts/import/go.scm
+++ b/guix/scripts/import/go.scm
@@ -115,10 +115,10 @@ that are not yet in Guix"))
(map package->definition*
(apply go-module-recursive-import arguments))
;; Single import.
- (let ((sexp (apply go-module->guix-package arguments)))
+ (let ((sexp (apply go-module->guix-package* arguments)))
(unless sexp
- (leave (G_ "failed to download meta-data for module '~a'~%")
- module-name))
+ (leave (G_ "failed to download meta-data for module '~a'.~%")
+ name))
(package->definition* sexp))))))
(()
(leave (G_ "too few arguments~%")))
diff --git a/tests/go.scm b/tests/go.scm
index b088ab50d2..929a8b39d1 100644
--- a/tests/go.scm
+++ b/tests/go.scm
@@ -286,6 +286,6 @@ package.")
(nix-base32-string->bytevector
"0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5")
#f)))
- (go-module->guix-package "github.com/go-check/check")))))))
+ (go-module->guix-package* "github.com/go-check/check")))))))
(test-end "go")
--
2.32.0
This bug report was last modified 3 years and 262 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.