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 KMcCCUjsxGElsgAAgWs5BA (envelope-from ) for ; Thu, 23 Dec 2021 22:38:16 +0100 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 iD3bBEjsxGHuOgAAB5/wlQ (envelope-from ) for ; Thu, 23 Dec 2021 21:38:16 +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 7C2F430852 for ; Thu, 23 Dec 2021 22:38:15 +0100 (CET) Received: from localhost ([::1]:47746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0Vmw-0007zq-8Q for larch@yhetil.org; Thu, 23 Dec 2021 16:38:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Vmk-0007y7-4S for guix-patches@gnu.org; Thu, 23 Dec 2021 16:38:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:51744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n0Vmj-0003wi-Pb for guix-patches@gnu.org; Thu, 23 Dec 2021 16:38:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n0Vmj-0007UN-Jy for guix-patches@gnu.org; Thu, 23 Dec 2021 16:38:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52724] [PATCH v2] guix: Prepare the UI for continuable &warning exceptions. References: <20211221224029.2091-1-attila@lendvai.name> In-Reply-To: <20211221224029.2091-1-attila@lendvai.name> Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 23 Dec 2021 21:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52724 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52724@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 52724-submit@debbugs.gnu.org id=B52724.164029543228718 (code B ref 52724); Thu, 23 Dec 2021 21:38:01 +0000 Received: (at 52724) by debbugs.gnu.org; 23 Dec 2021 21:37:12 +0000 Received: from localhost ([127.0.0.1]:35057 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0Vlv-0007T8-Tr for submit@debbugs.gnu.org; Thu, 23 Dec 2021 16:37:12 -0500 Received: from mail-ed1-f45.google.com ([209.85.208.45]:44974) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0Vlu-0007Su-8V for 52724@debbugs.gnu.org; Thu, 23 Dec 2021 16:37:10 -0500 Received: by mail-ed1-f45.google.com with SMTP id w16so26117449edc.11 for <52724@debbugs.gnu.org>; Thu, 23 Dec 2021 13:37:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4K1l0uRsHnuYqJZyvkJW2n64eyXXKf33p6OFmdrccxg=; b=Tgm6XuKy5kP2RcogegUUo304xRBJhnVMQROTUODZc84Qg/5+LXRiLKtrozdA7Ldylz sG5cWy0hIJ7mecZfAAfhINOtnPqnfuduCMU8L41l9ESAzhzZckULclo4QI7U/bqFSY5m zdvmPB1bn5MPdAv6KEN67oFU5kycFUue5unXWjCbvcjKTRSUx9b3mjn6Q2CEWuvDkvNy lfMKw1mzJWtLJQyAZXaRIyHnEYXDfk2g6aRnGXxkoXIsLZS1PZERO9+7ge0PNWSMFAyB Q2ayqBHA+jToF2aUvs415ZhI0TdW0MPQNznT44c90TXE+BVPKlOCv7Ql1VZURxTEAm4q 5ceA== 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 :mime-version:content-transfer-encoding; bh=4K1l0uRsHnuYqJZyvkJW2n64eyXXKf33p6OFmdrccxg=; b=Qz2iMKOEoj7BHRnPCPSzsX+amb+avhWDASreYCc+blrPlcYMqyVujyr+daJqyHI/Pu Bd28/BGS0J5N6kACXRL0x1usBrhk58TvxDUfUlyasuGLNRKAJF/HoMNl6y63xcPDMHlz Eh/SzPssuAhdoP7j6/xyremuEkGMMEvZdboatA6yh/prP/BELnSfr5IXo39gaVT2H+3N BW4De7P74PsCrF/vn1g5++jYm8SG6BL6oAu5IWvcm0JFqBERB+9DM2MeNnVSxcdqQgMy OFmFUhs9AN4Q8n6/jIG2HeFofY1TA2Unbt28YeIqRcmUDJBLcYUpOUuXz2AUYeVoYJ9F yobg== X-Gm-Message-State: AOAM530qgJPH+qe4BmjvX4LQOu5xzMh1v8buAZlXIIZyMZrGrWWHXmLN ljOxgaYUERoX9/pFni4jqDD1SUSG5pyRgQ== X-Google-Smtp-Source: ABdhPJxJiL+yLKW8LjADUm5QMiHJBA19wpeffhvCX0fz675NNjjD0KgJ8G+VlW3EqnCqiccoHRl0Ig== X-Received: by 2002:a05:6402:1203:: with SMTP id c3mr3536114edw.253.1640295424367; Thu, 23 Dec 2021 13:37:04 -0800 (PST) Received: from lelap.lan (catv-80-99-178-127.catv.broadband.hu. [80.99.178.127]) by smtp.gmail.com with ESMTPSA id la26sm2055932ejc.91.2021.12.23.13.37.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 13:37:03 -0800 (PST) From: Attila Lendvai Date: Thu, 23 Dec 2021 22:16:27 +0100 Message-Id: <20211223211626.2753-1-attila@lendvai.name> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640295495; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=4K1l0uRsHnuYqJZyvkJW2n64eyXXKf33p6OFmdrccxg=; b=CA5nkB6TQHFb7pXeCLefrP9sNy1Mi7Ty+slNsRqAPoP/QTu/0Ox8r+7atdPjarMB6Vx9xI B5l8gdaIva4GuxQteloreb0UKa1efTBF5Lf/ywAvAvzTZxZaIgy00c6dX7TssUyiG1K+HF lWbRGJv9Jgc7VydvNPV7PwEM+aUVWM8qkKFPgbFYPpqPpsElhCtx8L2ndb7KX90lHCK9TL 3J43UlC/1uaGRn79faw7Tq0DC5gAi1LCblon8YFCZLNmmxTFeEAt33irTAzWE5CbspIFsY N6Uy197e5RsXQLTrJgatEOVtSyLmwiCEtC5MDnPb3NRnsHjQt+MCV0CkoDIM5w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640295495; a=rsa-sha256; cv=none; b=FqBQOw7f8/qz/eSM84uEZcJAMQP4i4c4ZOQELM4/T14DCnrdaZIxZ9KKCl4dAU+fQKQmrK S6AiUNrWsjrT9b2Lh6s3HDU2Bss0vlwFU3n8fSsifvmCobp0mpK0cuekDgbllT4OlC2bzx MGXte2o2Q+4YZzFTO1wtrNRspC2YVi33mNtRJD0jI1rCKbdaTz5pPKHfmGITPb+UYfNOOf TrFCcfXMwesT2zjc0WnQU04z5usk5tExY1fZ3LIh1dYVLbxOBAj1Hy0rLI/c5t99Ykqci5 u+jtBY/gFHaqI1wZCtq+oH2C6JWPp3ns5LhJEmbhirpd+6HhNqA29fRrjgj3iw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=Tgm6XuKy; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.55 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=Tgm6XuKy; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 7C2F430852 X-Spam-Score: -1.55 X-Migadu-Scanner: scn0.migadu.com X-TUID: PMoKfRaLh03j * guix/store.scm (call-with-store): Use RAISE-CONTINUABLE to resignal exceptions. This is needed for a later commit that uses continuable exceptions from within GIT-AUTHENTICATE to signal warnings that are meant to be displayed to the user. The reason for this is that this way unit tests can use a handler to explicitly check that a warning was indeed signalled. * guix/ui.scm (call-with-error-handling): Handle &WARNING type exceptions by printing them to the user, and then continuing at the place where they were signalled at. (maybe-display-fix-hint): New procedure. * guix/diagnostics.scm (emit-formatted-warning): New procedure. Exported. --- thanks for the feedback! i've applied everything you pointed out. i didn't merge it with the formatted-message? entry, because i'd like a place where every warning ends up. instead, i have factored out a maybe-display-fix-hint function, and used it there, too. > Also, you can't meaningfully stringify a condition. in case of warnings, you're right. i just have a knee-jerk reaction against silently swallowing errors, and it kicked in here, too. > Also, a test or two would be great i don't really know how to write a test for this. the way i was testing it is that a future commit will add a warning when the channel intro commit doesn't set up .guix-authorizations properly, and i had set up a branch from which i tried to pull. guix/diagnostics.scm | 4 ++++ guix/store.scm | 7 +++++-- guix/ui.scm | 30 ++++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/guix/diagnostics.scm b/guix/diagnostics.scm index 337a73c1a2..8e13e5e30a 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? @@ -163,6 +164,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 a93e9596d9..a2b3b2f05a 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 bd999103ff..96f9db722c 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) @@ -299,6 +301,11 @@ (define (module