From: Sarah Morgensen <iskarian@mgsn.dev>
To: 49196@debbugs.gnu.org
Cc: zimoun <zimon.toutoune@gmail.com>
Subject: [bug#49196] [PATCH v6 3/3] import: go: Improve error handling.
Date: Fri, 6 Aug 2021 11:05:17 -0700 [thread overview]
Message-ID: <a4cee8f58e2187619e7a7fc3fc9b73ca04ae696f.1628272957.git.iskarian@mgsn.dev> (raw)
In-Reply-To: <5d11fc04400d26de06efba709cf2e1b14a1d5949.1628272957.git.iskarian@mgsn.dev>
From: zimoun <zimon.toutoune@gmail.com>
* guix/import/go.scm (go-module->guix-package*): Handle errors, remove
memoize.
(go-module-recursive-import): Remove 'guard', add memoize.
* guix/scripts/import/go.scm (guix-import-go): Adjust.
* tests/go.scm: Adjust.
---
guix/import/go.scm | 50 +++++++++++++++++++++++---------------
guix/scripts/import/go.scm | 6 ++---
tests/go.scm | 2 +-
3 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/guix/import/go.scm b/guix/import/go.scm
index a4775f973f..4755571209 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -63,6 +64,7 @@
#:use-module (web uri)
#:export (go-module->guix-package
+ go-module->guix-package*
go-module-recursive-import))
;;; Commentary:
@@ -646,7 +648,28 @@ 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->guix-package*
+ (lambda args
+ ;; Disable output buffering so that the following warning gets printed
+ ;; consistently.
+ (setvbuf (current-error-port) 'none)
+ (let ((package-name (match args ((name _ ...) name))))
+ (guard (c ((http-get-error? c)
+ (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.~%")
+ package-name
+ (uri->string (http-get-error-uri c))
+ (http-get-error-code c)
+ (http-get-error-reason c))
+ (values #f '()))
+ (else
+ (warning (G_ "Failed to import package ~s.
+reason: ~s.~%")
+ package-name
+ (exception-args c))
+ (values #f '())))
+ (apply go-module->guix-package args)))))
(define* (go-module-recursive-import package-name
#:key (goproxy "https://proxy.golang.org")
@@ -656,23 +679,12 @@ hint: use one of the following available versions ~a\n"
(recursive-import
package-name
#:repo->guix-package
- (lambda* (name #:key version repo)
- ;; Disable output buffering so that the following warning gets printed
- ;; consistently.
- (setvbuf (current-error-port) 'none)
- (guard (c ((http-get-error? c)
- (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
- (uri->string (http-get-error-uri c))
- (http-get-error-code c)
- (http-get-error-reason c))
- (values #f '())))
- (receive (package-sexp dependencies)
- (go-module->guix-package* name #:goproxy goproxy
- #:version version
- #:pin-versions? pin-versions?)
- (values package-sexp dependencies))))
+ (memoize
+ (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 e08a1e427e..f5cfea8683 100644
--- a/guix/scripts/import/go.scm
+++ b/guix/scripts/import/go.scm
@@ -112,10 +112,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 6749f4585f..9e7223ff7c 100644
--- a/tests/go.scm
+++ b/tests/go.scm
@@ -410,6 +410,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.31.1
next prev parent reply other threads:[~2021-08-06 18:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 20:49 [bug#49196] [PATCH] import: utils: 'recursive-import' skips unfound packages Sarah Morgensen via Guix-patches via
2021-06-24 12:21 ` zimoun
2021-06-25 4:22 ` Sarah Morgensen via Guix-patches via
2021-06-25 6:53 ` zimoun
2021-06-25 16:47 ` zimoun
2021-06-25 4:48 ` [bug#49196] [PATCH v2] " Sarah Morgensen via Guix-patches via
2021-06-25 16:37 ` [bug#49196] [PATCH v3 1/3] import: go: Return false for package not found zimoun
2021-06-25 16:37 ` [bug#49196] [PATCH v3 2/3] import: utils: Skip not found packages zimoun
2021-06-25 16:37 ` [bug#49196] [PATCH v3 3/3] import: go: Improve error handling zimoun
2021-06-27 4:46 ` [bug#49196] [PATCH] import: utils: 'recursive-import' skips unfound packages Sarah Morgensen via Guix-patches via
2021-06-28 11:42 ` zimoun
2021-06-28 17:13 ` Sarah Morgensen via Guix-patches via
2021-06-28 16:20 ` [bug#49196] [PATCH v4 1/3] import: go: Return false for package not found zimoun
2021-06-28 16:20 ` [bug#49196] [PATCH v4 2/3] import: utils: Skip not found packages zimoun
2021-06-28 16:20 ` [bug#49196] [PATCH v4 3/3] import: go: Improve error handling zimoun
2021-06-29 10:52 ` [bug#49196] [PATCH v5 1/3] import: go: Return false for package not found zimoun
2021-06-29 10:52 ` [bug#49196] [PATCH v5 2/3] import: utils: Skip not found packages zimoun
2021-06-29 10:52 ` [bug#49196] [PATCH v5 3/3] import: go: Improve error handling zimoun
2021-08-06 18:04 ` [bug#49196] [PATCH v6 1/3] import: go: Return false for package not found Sarah Morgensen
2021-08-06 18:05 ` [bug#49196] [PATCH v6 2/3] import: utils: Skip not found packages Sarah Morgensen
2021-08-06 18:05 ` Sarah Morgensen [this message]
2021-09-01 21:39 ` bug#49196: [PATCH] "guix import go" Improve error handling Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a4cee8f58e2187619e7a7fc3fc9b73ca04ae696f.1628272957.git.iskarian@mgsn.dev \
--to=iskarian@mgsn.dev \
--cc=49196@debbugs.gnu.org \
--cc=zimon.toutoune@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.