From patchwork Mon Oct 18 15:57:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Attila Lendvai X-Patchwork-Id: 33918 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 1043C27BBE3; Mon, 18 Oct 2021 17:03:00 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 95A9327BBE1 for ; Mon, 18 Oct 2021 17:02:59 +0100 (BST) Received: from localhost ([::1]:52458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcV6I-00032s-Mk for patchwork@mira.cbaines.net; Mon, 18 Oct 2021 12:02:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcV2V-00084Q-Up for guix-patches@gnu.org; Mon, 18 Oct 2021 11:59:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36780) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcV2U-00036g-LD for guix-patches@gnu.org; Mon, 18 Oct 2021 11:59:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mcV2U-00072B-KZ for guix-patches@gnu.org; Mon, 18 Oct 2021 11:59:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50814] [PATCH 3/5] guix: Prepare the UI for continuable &warning exceptions. Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 18 Oct 2021 15:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50814 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50814@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 50814-submit@debbugs.gnu.org id=B50814.163457269226955 (code B ref 50814); Mon, 18 Oct 2021 15:59:02 +0000 Received: (at 50814) by debbugs.gnu.org; 18 Oct 2021 15:58:12 +0000 Received: from localhost ([127.0.0.1]:48323 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcV1g-00070b-Em for submit@debbugs.gnu.org; Mon, 18 Oct 2021 11:58:12 -0400 Received: from mail-ed1-f50.google.com ([209.85.208.50]:46839) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mcV1X-0006z8-1Y for 50814@debbugs.gnu.org; Mon, 18 Oct 2021 11:58:03 -0400 Received: by mail-ed1-f50.google.com with SMTP id z20so867796edc.13 for <50814@debbugs.gnu.org>; Mon, 18 Oct 2021 08:58:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L7y/+COJjYPaozopnnQ+sBjtLR+/Y2RyAcjzRtsyLQc=; b=ibAfSRkNJk8HZXM0jK6b+ySD2dgUIF4xH9ZfyW4YGppNho1/Up0F1+uYlq1nyezmuL 672I+TgHjrfCAKsvtxU2sKM/F+mpDf00T9AOJ2zdfY6UN4zqrj2J3sNMlNTeBXnpJyqn 9fB4iNl3IejJFAZ7BHtTZVOyaboWak2KoVaL+CRRXZmX82zn7cmEd03zrBq0QfXsknvp cQkrDlWbmV4mjlG/kvJqmwTR7ZYHZWJw5aMicp9HZ1MNhnIETMxHoZfF8ChP5Q8FcrOH eolgW3S21dF3PI+0Evix6mgZXSN3cg54Id6x7qFLkMqIhIwPaeA6yYJRKpBtuJzKsWcH 0sgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=L7y/+COJjYPaozopnnQ+sBjtLR+/Y2RyAcjzRtsyLQc=; b=dlNDy6al67AKVRK/yGp6ARazOO7w7buVnhFL1OWcyasis6Sc1dmxe+hTvyjDPAc+zM hXSJb1q/MfMGv8KYFCN+JCKs00mQGcY4x9h6ykFx5ygN0wFb53itObZUM1pFk/18hq6a wibm0gfj7wJ4P/pvi1AGm2bXW2h0Fs4io9B6uMCDS1TNzKC4NotvDhO1QkwzsXHkQFG/ uNtbSFG2dUlU5efAaDGXLREY0qIUAigASVxIHyUhUsYFw7G9Rf2OYxsjt2+bLdeekQxW TXYawG1mjgEHfI+/MFlHIm1zUdhjLmTufkoCosv3Kz3VLhW8gq3y0sgrg2lMfR9s+HM5 atyg== X-Gm-Message-State: AOAM532piEvBjc+UBntcRkpPtNomXk6LioYYVxvrteZ0YYMVa61joVws JbzlxMYrk14O8Q4y9Gv8WES6kn0Zwsk= X-Google-Smtp-Source: ABdhPJzUB2aXYgZtnQtRRDX6Jik7IT3O8L1Fol4X67mEaG2skpWxVJ/UdQEkH9jpa81GNMZqwUm0BA== X-Received: by 2002:aa7:ccc1:: with SMTP id y1mr46457408edt.177.1634572666944; Mon, 18 Oct 2021 08:57:46 -0700 (PDT) Received: from localhost.localdomain ([2a02:ab88:3710:6480:8fb4:66e9:57c0:8a0a]) by smtp.gmail.com with ESMTPSA id n22sm8762059eja.120.2021.10.18.08.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 08:57:46 -0700 (PDT) From: Attila Lendvai Date: Mon, 18 Oct 2021 17:57:32 +0200 Message-Id: <20211018155734.5175-3-attila@lendvai.name> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211018155734.5175-1-attila@lendvai.name> References: <20211018155734.5175-1-attila@lendvai.name> 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" X-getmail-retrieved-from-mailbox: Patches * guix/store.scm (call-with-store): Use dynamic-wind so that continuable exceptions are not broken by being re-raised as non-continuable. This is needed for a later commit that uses continuable exceptions from within git-authenticate to signal warnings to the user. The reason for this is that this way tests can explicitly check that a warning was signalled in certain situations. * guix/ui.scm (call-with-error-handling): Handle &warning type exceptions by printing them to the user, and then continuing at the place they were signalled at. * guix/diagnostics.scm (emit-formatted-warning): New exported function. --- guix/diagnostics.scm | 4 ++++ guix/store.scm | 7 +++++-- guix/ui.scm | 11 ++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/guix/diagnostics.scm b/guix/diagnostics.scm index 6a792febd4..343213fb45 100644 --- a/guix/diagnostics.scm +++ b/guix/diagnostics.scm @@ -48,6 +48,7 @@ (define-module (guix diagnostics) formatted-message? formatted-message-string formatted-message-arguments + emit-formatted-warning &fix-hint fix-hint? @@ -161,6 +162,9 @@ (define-syntax-rule (leave args ...) (report-error args ...) (exit 1))) +(define* (emit-formatted-warning fmt . args) + (emit-diagnostic fmt args #:prefix (G_ "warning: ") #:colors %warning-color)) + (define* (emit-diagnostic fmt args #:key location (colors (color)) (prefix "")) "Report diagnostic message FMT with the given ARGS and the specified diff --git a/guix/store.scm b/guix/store.scm index 89a719bcfc..1b177cc952 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -34,6 +34,8 @@ (define-module (guix store) #:use-module (guix profiling) #:autoload (guix build syscalls) (terminal-columns) #:use-module (rnrs bytevectors) + #:use-module ((rnrs conditions) #:select (warning?)) + #:use-module ((rnrs exceptions) #:select (raise-continuable)) #:use-module (ice-9 binary-ports) #:use-module ((ice-9 control) #:select (let/ec)) #:use-module (ice-9 atomic) @@ -661,8 +663,9 @@ (define (thunk) (apply values results))))) (with-exception-handler (lambda (exception) - (close-connection store) - (raise-exception exception)) + (unless (warning? exception) + (close-connection store)) + (raise-continuable exception)) thunk))) (define-syntax-rule (with-store store exp ...) diff --git a/guix/ui.scm b/guix/ui.scm index 1428c254b3..88940f99ef 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -69,6 +69,8 @@ (define-module (guix ui) #:use-module (srfi srfi-31) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) + #:use-module ((rnrs conditions) + #:select (warning?)) #:autoload (ice-9 ftw) (scandir) #:use-module (ice-9 match) #:use-module (ice-9 format) @@ -689,7 +691,14 @@ (define (port-filename* port) (and (not (port-closed? port)) (port-filename port))) - (guard* (c ((package-input-error? c) + (guard* (c ((warning? c) + (if (formatted-message? c) + (apply emit-formatted-warning + (formatted-message-string c) + (formatted-message-arguments c)) + (emit-formatted-warning "~a" c)) + '()) + ((package-input-error? c) (let* ((package (package-error-package c)) (input (package-error-invalid-input c)) (location (package-location package))