From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id GT85H7aabWEAEgAAgWs5BA (envelope-from ) for ; Mon, 18 Oct 2021 18:03:02 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 4LJIGraabWF4dQAA1q6Kng (envelope-from ) for ; Mon, 18 Oct 2021 16:03:02 +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 1BB54CDA7 for ; Mon, 18 Oct 2021 18:03:02 +0200 (CEST) Received: from localhost ([::1]:52458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcV6L-00032s-4i for larch@yhetil.org; Mon, 18 Oct 2021 12:03:01 -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 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=1634572982; 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=L7y/+COJjYPaozopnnQ+sBjtLR+/Y2RyAcjzRtsyLQc=; b=frKFPXanScbhB0rUvrFPMHCzIByKNneOtO3QWPEgCbT51l55XQFIS0TS5eABhiF2wJgo7Y jNJygsD3FSY4A2YYHDvlAAJfcJ0QSMVO5AGdNzZnbGY4VfAXUJW7cPjHP2iQLxuO+VaGkq GmF/JovVUWzGymTqgGSndlb6VIVI1hWnIMWsrdwaKT3MDgjdX/gEMkdvoMJPbLZznIA4M1 A+rj6vKJXHeY8kGhFWj9RpjB4o2MXUWyQVaJwZz9Q+shw/yP4T6/jRS/kdxWmJ+xwpl7FS N4GNXESBvI65Sx30xTnZINhOYjVC1Kb+mjUUljdvzMEI/CLA1aPoNLKRAF2OEw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1634572982; a=rsa-sha256; cv=none; b=NvIKSu+BfKagWqM/5ZfdBJMytWYe4qH1weosq1VNiDgNXh0Iyb0a374ano9MT85+A2AcYt 5TUb19OaUqS0CPP7z5NRY83hQyk+LpqMP2wBMXvnA64shhmsF662VGFymtq8XsvIQNz+b3 bTfY92OZDcs+l5S4m822mnw0uVDzx1E5VYBbaxNIoadJAqbhDDzCzU9tG1fpPLjhhQxKwa hrr1Kw4yTZLcgqsmL7WxFs95rUPO4eDixUg/3agad5cdZtVf8sTdJKY6k3Fh0AIkPR1oMs I8FEhpZWex86ma1dCWwm6crHBwCPi2SBF2Iao7YHuktclzTkDVpexjBuddTlGg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=ibAfSRkN; 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.57 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=ibAfSRkN; 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: 1BB54CDA7 X-Spam-Score: 3.57 X-Migadu-Scanner: scn0.migadu.com X-TUID: 1FwOtzTFnB7z * 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)) -- 2.33.0