From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id U2LIFT++rmCYYAEAgWs5BA (envelope-from ) for ; Wed, 26 May 2021 23:31:43 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id cHTJED++rmB+DQAAbx9fmQ (envelope-from ) for ; Wed, 26 May 2021 21:31:43 +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 B3EB212A2E for ; Wed, 26 May 2021 23:31:42 +0200 (CEST) Received: from localhost ([::1]:41258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lm17t-0004wa-MQ for larch@yhetil.org; Wed, 26 May 2021 17:31:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lm0vf-0002Sl-6j for guix-patches@gnu.org; Wed, 26 May 2021 17:19:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38498) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lm0ve-0008LK-Tn for guix-patches@gnu.org; Wed, 26 May 2021 17:19:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lm0ve-0003yn-Pr for guix-patches@gnu.org; Wed, 26 May 2021 17:19:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48685] [PATCH 2/2] ui, lint: Simplify exception handling in Guile 3 style. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 26 May 2021 21:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48685 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48685@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 48685-submit@debbugs.gnu.org id=B48685.162206391515258 (code B ref 48685); Wed, 26 May 2021 21:19:02 +0000 Received: (at 48685) by debbugs.gnu.org; 26 May 2021 21:18:35 +0000 Received: from localhost ([127.0.0.1]:50043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lm0vD-0003y1-Cr for submit@debbugs.gnu.org; Wed, 26 May 2021 17:18:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43944) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lm0v9-0003xZ-BI for 48685@debbugs.gnu.org; Wed, 26 May 2021 17:18:31 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:48782) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lm0v3-0007zP-RY; Wed, 26 May 2021 17:18:25 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42918 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lm0v3-0003RS-IA; Wed, 26 May 2021 17:18:25 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Wed, 26 May 2021 23:18:14 +0200 Message-Id: <20210526211814.17116-2-ludo@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210526211814.17116-1-ludo@gnu.org> References: <20210526211814.17116-1-ludo@gnu.org> 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=1622064703; 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; bh=uMlR1BkYdRqWJSyQ42OD5EjN0DPVrZ1IrF3/L22B/1U=; b=MSarmirs3jHzLRZ2mAtJTzBDW1kcGD8YXNKsPbsQcWBcZtj8twTO+51VMrWd3/qVEoxlAN dcbI+BXfdkf+Bwl0Rq7W5K2IGVWIXAJ2fOlacjOlvVJjDksfaC/BGS7PmUy7UsT3XpUTYY QXWkcPVR4sIP4Cx9neAXh1H+e8NzfI27Sv6rL0FzaXOEtEVfVoPNqCaMhNB0un6S1uSF8W kZLPsBmZoouU7tDRja5bwPn8MKxj2AZvWgeYI/0hVzBa9i85WEXJLWFwI8kmtk2JnX0qfg mJBYahUdK5Pgs4JX/09t6xtEZ4lOZvOww/+Z4Lmb9BIhRnN1wvou04DReGw9+w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1622064703; a=rsa-sha256; cv=none; b=Q4Qci5foj8vowyvr4i9GsQFFuIRdT4P5Ng/RA9BL1UIY5PgBbYk9LyIKWz2Qr/n/wKLOZi mHenZ5VQaRsVsVfYBxg0jpbE6GUeacJYmyS93lhx6mNphuEztDKIdizMZPeZFtik6gRKaG iojmXJJgply89rx1sjD97FFkaEhpFKs44ynIRrJJM2xrJqhRc3TxMcxY5z+BSUhHwmEKug GXCx4xEGIyYwo4oHBFFpgxejqYcN4NAKauuqklS8uY00/wRzbG9ZXvXQv8cAzpWVkvFzhu pOWOUpfV6iBxy/28i8UBGQV9Rh+wjtfp/nmO/nVHZ5KwdNgrL1ixjoStk8Uaww== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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: 2.07 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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: B3EB212A2E X-Spam-Score: 2.07 X-Migadu-Scanner: scn1.migadu.com X-TUID: eCwM5FCZ54XG * guix/lint.scm (check-derivation)[try]: Remove "catch #t" wrapping. * guix/ui.scm (call-with-error-handling): Remove "catch 'system-error" and move 'system-error handling to the &exception-with-kind-and-args clause. --- guix/lint.scm | 70 +++++++++++++++++++++++---------------------------- guix/ui.scm | 14 +++++------ 2 files changed, 39 insertions(+), 45 deletions(-) diff --git a/guix/lint.scm b/guix/lint.scm index 023a179ea6..41dd5d0633 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -1010,45 +1010,39 @@ descriptions maintained upstream." (define* (check-derivation package #:key store) "Emit a warning if we fail to compile PACKAGE to a derivation." (define (try store system) - (catch #t ;TODO: Remove 'catch' when Guile 2.x is no longer supported. - (lambda () - (guard (c ((store-protocol-error? c) - (make-warning package - (G_ "failed to create ~a derivation: ~a") - (list system - (store-protocol-error-message c)))) - ((exception-with-kind-and-args? c) - (make-warning package - (G_ "failed to create ~a derivation: ~s") - (list system - (cons (exception-kind c) - (exception-args c))))) - ((message-condition? c) - (make-warning package - (G_ "failed to create ~a derivation: ~a") - (list system - (condition-message c)))) - ((formatted-message? c) - (let ((str (apply format #f - (formatted-message-string c) - (formatted-message-arguments c)))) - (make-warning package - (G_ "failed to create ~a derivation: ~a") - (list system str))))) - (parameterize ((%graft? #f)) - (package-derivation store package system #:graft? #f) + (guard (c ((store-protocol-error? c) + (make-warning package + (G_ "failed to create ~a derivation: ~a") + (list system + (store-protocol-error-message c)))) + ((exception-with-kind-and-args? c) + (make-warning package + (G_ "failed to create ~a derivation: ~s") + (list system + (cons (exception-kind c) + (exception-args c))))) + ((message-condition? c) + (make-warning package + (G_ "failed to create ~a derivation: ~a") + (list system + (condition-message c)))) + ((formatted-message? c) + (let ((str (apply format #f + (formatted-message-string c) + (formatted-message-arguments c)))) + (make-warning package + (G_ "failed to create ~a derivation: ~a") + (list system str))))) + (parameterize ((%graft? #f)) + (package-derivation store package system #:graft? #f) - ;; If there's a replacement, make sure we can compute its - ;; derivation. - (match (package-replacement package) - (#f #t) - (replacement - (package-derivation store replacement system - #:graft? #f)))))) - (lambda args - (make-warning package - (G_ "failed to create ~a derivation: ~s") - (list system args))))) + ;; If there's a replacement, make sure we can compute its + ;; derivation. + (match (package-replacement package) + (#f #t) + (replacement + (package-derivation store replacement system + #:graft? #f)))))) (define (check-with-store store) (filter lint-warning? diff --git a/guix/ui.scm b/guix/ui.scm index 6b0155f563..d3e01f846d 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -812,7 +812,12 @@ directories:~{ ~a~}~%") ;; been unwound when we re-raise, since that would otherwise show ;; useless backtraces. (((exception-predicate &exception-with-kind-and-args) c) - (raise c)) + (if (eq? 'system-error (exception-kind c)) ;EPIPE & co. + (match (exception-args c) + ((proc format-string format-args . _) + (leave (G_ "~a: ~a~%") proc + (apply format #f format-string format-args)))) + (raise c))) ((message-condition? c) ;; Normally '&message' error conditions have an i18n'd message. @@ -822,12 +827,7 @@ directories:~{ ~a~}~%") (when (fix-hint? c) (display-hint (condition-fix-hint c))) (exit 1))) - ;; Catch EPIPE and the likes. - (catch 'system-error - thunk - (lambda (key proc format-string format-args . rest) - (leave (G_ "~a: ~a~%") proc - (apply format #f format-string format-args)))))) + (thunk))) (define-syntax-rule (leave-on-EPIPE exp ...) "Run EXP... in a context where EPIPE errors are caught and lead to 'exit' -- 2.31.1