From patchwork Tue Feb 20 19:42:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 60814 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2E53927BBEA; Tue, 20 Feb 2024 19:42:58 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B846127BBE2 for ; Tue, 20 Feb 2024 19:42:57 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcW0q-0004Cq-Gx; Tue, 20 Feb 2024 14:42:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcW0o-0004Br-J9 for guix-patches@gnu.org; Tue, 20 Feb 2024 14:42:42 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcW0o-00015x-AT; Tue, 20 Feb 2024 14:42:42 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcW19-0002ZV-45; Tue, 20 Feb 2024 14:43:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#69291] [PATCH 3/5] scripts: substitute: Replace some leave calls with raise. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 20 Feb 2024 19:43:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69291 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69291@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 69291-submit@debbugs.gnu.org id=B69291.17084581809846 (code B ref 69291); Tue, 20 Feb 2024 19:43:03 +0000 Received: (at 69291) by debbugs.gnu.org; 20 Feb 2024 19:43:00 +0000 Received: from localhost ([127.0.0.1]:46677 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcW16-0002Yi-Ac for submit@debbugs.gnu.org; Tue, 20 Feb 2024 14:43:00 -0500 Received: from mira.cbaines.net ([212.71.252.8]:43158) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcW0y-0002Y0-BZ for 69291@debbugs.gnu.org; Tue, 20 Feb 2024 14:42:52 -0500 Received: from localhost (unknown [212.132.255.10]) by mira.cbaines.net (Postfix) with ESMTPSA id 0407A27BBE2 for <69291@debbugs.gnu.org>; Tue, 20 Feb 2024 19:42:30 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 17dacf27 for <69291@debbugs.gnu.org>; Tue, 20 Feb 2024 19:42:29 +0000 (UTC) From: Christopher Baines Date: Tue, 20 Feb 2024 19:42:25 +0000 Message-ID: <3a88dc8a8369278f86f3a51a99aa62d991ba997d.1708458147.git.mail@cbaines.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches These calls happen inside of with-error-handling, so the effect should be the same, but this opens up the possibility of using this code in a program that doesn't want to exit when one of these error conditions is met. Change-Id: I15d963615d85d419559fa0f4333fa4dc1dfbfd3b * guix/scripts/substitute.scm (download-nar, process-substitution): Use raise formatted-message rather than leave. Change-Id: Idd0880206b69e3903e19e0536b87d65a52c200d5 --- guix/scripts/substitute.scm | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 575fa2a0b3..1875a4332d 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -495,8 +495,10 @@ (define* (download-nar narinfo destination #:keep-alive? #t #:buffered? #f)))) (else - (leave (G_ "unsupported substitute URI scheme: ~a~%") - (uri->string uri))))) + (raise + (formatted-message + (G_ "unsupported substitute URI scheme: ~a~%") + (uri->string uri)))))) (define (try-fetch choices) (match choices @@ -511,9 +513,11 @@ (define* (download-nar narinfo destination (G_ "Downloading ~a...~%") (uri->string uri))) (values port uri compression download-size)))) (() - (leave (G_ "no valid nar URLs for ~a at ~a~%") - (narinfo-path narinfo) - (narinfo-uri-base narinfo))))) + (raise + (formatted-message + (G_ "no valid nar URLs for ~a at ~a~%") + (narinfo-path narinfo) + (narinfo-uri-base narinfo)))))) ;; Delete DESTINATION first--necessary when starting over after a failed ;; download. @@ -678,8 +682,10 @@ (define* (process-substitution port store-item destination (cut valid-narinfo? <> acl)))) (unless narinfo - (leave (G_ "no valid substitute for '~a'~%") - store-item)) + (raise + (formatted-message + (G_ "no valid substitute for '~a'~%") + store-item))) (guard (c ((network-error? c) (when (http-get-error? c)