From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iHPEMBR6DWG9qwAAgWs5BA (envelope-from ) for ; Fri, 06 Aug 2021 20:06:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WFdlLBR6DWFWcgAAB5/wlQ (envelope-from ) for ; Fri, 06 Aug 2021 18:06:12 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AF09B3268 for ; Fri, 6 Aug 2021 20:06:11 +0200 (CEST) Received: from localhost ([::1]:40496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC4EU-0008Da-OL for larch@yhetil.org; Fri, 06 Aug 2021 14:06:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC4EM-0008Bs-LE for guix-patches@gnu.org; Fri, 06 Aug 2021 14:06:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mC4EM-0008TJ-Eh for guix-patches@gnu.org; Fri, 06 Aug 2021 14:06:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mC4EM-0000lG-AC for guix-patches@gnu.org; Fri, 06 Aug 2021 14:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49196] [PATCH v6 3/3] import: go: Improve error handling. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 06 Aug 2021 18:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49196 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49196@debbugs.gnu.org Cc: zimoun Received: via spool by 49196-submit@debbugs.gnu.org id=B49196.16282731252866 (code B ref 49196); Fri, 06 Aug 2021 18:06:02 +0000 Received: (at 49196) by debbugs.gnu.org; 6 Aug 2021 18:05:25 +0000 Received: from localhost ([127.0.0.1]:51312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mC4Dl-0000kA-5X for submit@debbugs.gnu.org; Fri, 06 Aug 2021 14:05:25 -0400 Received: from out2.migadu.com ([188.165.223.204]:30607) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mC4Dj-0000ju-Ca for 49196@debbugs.gnu.org; Fri, 06 Aug 2021 14:05:24 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1628273121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s1inxFO+F2xzKSJHxztFV6a2bxDmmhtaUk7aiendReo=; b=Y4JU98yaNGershbRxo6UROr3H8lDWUgktc3JmdWSpMn575r+suzJWRqRx7ftFmStgFG7C6 qauf4/BDBNj5jtnWy461hlPOdgqDVQ4wlp2nAh8E8ZlgrnyqGWD6x6Mkj6c2Ie8LLvdVq8 wWJKBDKBY93NqT6e9liM8boLuTpUcN0= From: Sarah Morgensen Date: Fri, 6 Aug 2021 11:05:17 -0700 Message-Id: In-Reply-To: <5d11fc04400d26de06efba709cf2e1b14a1d5949.1628272957.git.iskarian@mgsn.dev> References: <5d11fc04400d26de06efba709cf2e1b14a1d5949.1628272957.git.iskarian@mgsn.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Auth-User: iskarian@mgsn.dev X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1628273171; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=s1inxFO+F2xzKSJHxztFV6a2bxDmmhtaUk7aiendReo=; b=IVB6XLTtl0qVFA6XjmXa2GXW5R1TchFtntoZFSXc9gCZITONv1YI9uBRNK+aC+irhlRUIQ G9F7iXWFuJMVrnD5THX1jKkUH77q3QR6rNHnnqX+d5m1zb1BbLVcNBLEGDmjUtdSGoza+/ vfxBKiVQqanzSdXJFO5Mpr0wpuII2+3bnM3RNn65DcmbbrbYY2asT4/rsd0Nk62dj53qzu jx4ptyyNNf7VQYBmupNKvQ2gd6FbRhqRdpBjguUeoLWbU+tw3wCtZtC+hZmJ46Lzlds7oo s7evVH++Ix4FwhxvuAjtikDvJ5kBB7QEI/a6LzEeu2DPHvcKk3JAIYgz5VIi5w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628273171; a=rsa-sha256; cv=none; b=tnE+9SXwVNG28au7BmeK3R/4rqstU0XGJwjdPn2jI0CNKWZa2P4M12vxqKBlDeAW4I1XSo 2WjiYTE3GyWZkXwyzBLRGB6lRy4dTULleV/9rikboll0hyKOfwiAJuAsW/Qg//UlQBZ/v/ ctcZ6Wg8q4m/ha2Avs356KNO9hi9r1pGUxozRHR0WDFLZiXa6Q9Aj1Q4lqSfXs781k8mRE RW04zROSwJSL9j8077uOVmA7Rg7A02uBqZ9Ytk6HC6DAF6A/iyNQ1H6W8MehrIzxCp6ySL 19fSvz+ymfg12zB8TY6CeDx8iBdUxpTUqbVyJ0oPOPRT+yO4LgBv0/3e43/omQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=Y4JU98ya; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=Y4JU98ya; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mgsn.dev (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: AF09B3268 X-Spam-Score: -0.32 X-Migadu-Scanner: scn1.migadu.com X-TUID: kTU5m8MPWo3v From: zimoun * 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 ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2021 Sarah Morgensen +;;; Copyright © 2021 Simon Tournier ;;; ;;; 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