From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 8HHKI2xCU2GTPgEAgWs5BA (envelope-from ) for ; Tue, 28 Sep 2021 18:27:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iPltH2xCU2HXaAAAB5/wlQ (envelope-from ) for ; Tue, 28 Sep 2021 16:27:24 +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 480E636FB9 for ; Tue, 28 Sep 2021 18:27:24 +0200 (CEST) Received: from localhost ([::1]:46022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVFwx-0003cs-Fd for larch@yhetil.org; Tue, 28 Sep 2021 12:27:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVFwd-0003ES-E9 for guix-patches@gnu.org; Tue, 28 Sep 2021 12:27:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35244) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVFwd-0006zV-73 for guix-patches@gnu.org; Tue, 28 Sep 2021 12:27:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mVFwd-0005aj-3f; Tue, 28 Sep 2021 12:27:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50814] [PATCH 4/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: Tue, 28 Sep 2021 16:27:03 +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.163284642121471 (code B ref 50814); Tue, 28 Sep 2021 16:27:03 +0000 Received: (at 50814) by debbugs.gnu.org; 28 Sep 2021 16:27:01 +0000 Received: from localhost ([127.0.0.1]:46787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVFwb-0005a8-1h for submit@debbugs.gnu.org; Tue, 28 Sep 2021 12:27:01 -0400 Received: from mail-ed1-f52.google.com ([209.85.208.52]:38784) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVFwY-0005Zi-SN for 50814@debbugs.gnu.org; Tue, 28 Sep 2021 12:26:59 -0400 Received: by mail-ed1-f52.google.com with SMTP id dj4so85972042edb.5 for <50814@debbugs.gnu.org>; Tue, 28 Sep 2021 09:26:58 -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=Rjf4e4gbvvXnkiZqzq7K+EMEhoVB7jqYYfKwKV96M0c=; b=fqUOctpvf5IRH2IolRHtaz3SHCv80Syj88dNvRMOdW0Y42GLX4vG/2Ij7TPk/1c0Li eiSpdfQRNFkv7Bpvdj92qcHmdLOcMsRp4lBOx7hzdxsrJOjlXYX1sNiyK8L5wQTqRkI+ WjFxLhyP50vQaEAYOsFDG/Eh92OPETXN7XKNi1R9T0WlI8wdOXAfkQhBqwnxXR96d/CX 9TJpXz2mT0R+4if0ZrnvlMTlkXb+O0/fp39u+BDuVS7qRr/fI+C3qQQeEaRxdmsje9y8 txxueQGT4/Tnp4T6qXDK9FJQINSDJUiC+dQZcaXg5+flczSQ5Fs5zfQwlXIq10+2B4BG KKlw== 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=Rjf4e4gbvvXnkiZqzq7K+EMEhoVB7jqYYfKwKV96M0c=; b=kabtJJkdTf+Vrut+xdjVG6T7dmXzVVeKMZ5eJ6sZyOTEusYYdM/8M7adV8DfEc4KFu RRJLLE8gGr3RE6TYkmmR44kQ651YrhKeG+B9OqAK3kYkRHC8ttJoBTC8TRU46gKvzmbs NuLULefZsGpKDeLpo2HM96C153XlggtOgu1/tsctBswDmU3PLi62p0La2TpfeSpEf1Zg fwWrOUwUB92mL/D22UvWloWsnB9VFRiz3vOEETYPkV+WT2GXxV4ecKaGCdc6Z0tSlTjr BdxBN+q2Col5nQyf+7BZKbk5QvnpAD/M4id04GVwMz9OArSczPIcgCFVeYXevCRw3RNB H+aA== X-Gm-Message-State: AOAM531AYyBHa97Eo3xKsUcDxvLBQZ/ayFifYlbrENVnOvjnXbjio59L mjlqGWFlS9eKqcIMPT9yO4hU991hV9o= X-Google-Smtp-Source: ABdhPJxt5u2NcW+1G+w8vC2WZMhZkHv9OkpLEjcrel8aMhjMkgMFT5x0lvJD8G4zCzphwBz0xAHwOg== X-Received: by 2002:a17:907:9686:: with SMTP id hd6mr3608988ejc.331.1632846412631; Tue, 28 Sep 2021 09:26:52 -0700 (PDT) Received: from lelap.lan (catv-213-222-131-28.catv.broadband.hu. [213.222.131.28]) by smtp.gmail.com with ESMTPSA id f4sm3147720ejq.125.2021.09.28.09.26.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 09:26:52 -0700 (PDT) From: Attila Lendvai Date: Tue, 28 Sep 2021 18:24:06 +0200 Message-Id: <20210928162406.27205-4-attila@lendvai.name> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928162406.27205-1-attila@lendvai.name> References: <20210928162406.27205-1-attila@lendvai.name> 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1632846444; 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=Rjf4e4gbvvXnkiZqzq7K+EMEhoVB7jqYYfKwKV96M0c=; b=OHR2OfxOw3puvrp6PGcACNXWRjRwtZKN6jQpnz7Fi6vYJLkiw+XaVfDrXvFK4bTyCq+Dsn PC7uHrZUxsMcmYKNe2gQ5NyMfogYbeVcZ8LyVbEmw6vEin7wp78zrGHu2FO6S0reC1Ics9 03TwORBsCz4KoOzOH594/pcuimtFWk+d/pL/f1hZJSH5UI7TvrObxq0tbuJPYzARkDqAP/ 1sWUdXTBBxxpJk8kgETFZuFlaCK7PzxgX9VI+9UBvQ6LTlfoH3yvffN0o1nUQ6qvAQPEcu iTZrdbdpElKCYe4tuhXY98lkNa39cX1S9QcBcsMrwgLmd9MJ+hl6ptB0k+U/GQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632846444; a=rsa-sha256; cv=none; b=XL8X4bAYjTJFxD4W0Pe3IOuJUF8lSdWouW0vYJtAcBt01SRubAFlCMeM5etCjwnUfoS9Ca Onyc7vJfKggLSH9Xl0pCaxuPbJG3dTlTVlZCtrx4i6lvL32nevB9XmcUcnl9+bkKpkNX0p McPQUQt9vxdPCNQTyLWz9Yf/JDGiPEEBO3aurtHHgygU44ese4Z4xT6fXwSAOVvRRpPiR+ YBC80bNgZ8oTNc7uV1+GOMXqtTD3kvtDbHKeSreLIN+Xxd4GGznTO2V9eaSYnYjkTJOJRJ o/jGragX9y8A1lnPdZpH6xOqU1ZBXpUZFIpbnd4cI0sqEzRXnsyWZMhWTFR5og== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=fqUOctpv; dmarc=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-Spam-Score: 3.60 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=fqUOctpv; dmarc=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: 480E636FB9 X-Spam-Score: 3.60 X-Migadu-Scanner: scn0.migadu.com X-TUID: v8VbpHb7IPUP * 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 | 16 ++++++++++------ guix/ui.scm | 11 ++++++++++- 3 files changed, 24 insertions(+), 7 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 @@ formatted-message? formatted-message-string formatted-message-arguments + emit-formatted-warning &fix-hint fix-hint? @@ -161,6 +162,9 @@ messages." (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..33d4039037 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -45,6 +45,8 @@ #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:use-module (srfi srfi-39) + #:use-module ((rnrs conditions) + #:select (warning?)) #:use-module (ice-9 match) #:use-module (ice-9 vlist) #:use-module (ice-9 popen) @@ -651,19 +653,21 @@ connection. Use with care." (define (call-with-store proc) "Call PROC with an open store connection." - (let ((store (open-connection))) + (let ((store '())) (define (thunk) (parameterize ((current-store-protocol-version (store-connection-version store))) (call-with-values (lambda () (proc store)) (lambda results - (close-connection store) (apply values results))))) - (with-exception-handler (lambda (exception) - (close-connection store) - (raise-exception exception)) - thunk))) + (dynamic-wind + (lambda () + (set! store (open-connection))) + thunk + (lambda () + (close-connection store) + (set! store '()))))) (define-syntax-rule (with-store store exp ...) "Bind STORE to an open connection to the store and evaluate EXPs; 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 @@ #: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 @@ evaluating the tests and bodies of CLAUSES." (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)) -- 2.33.0