From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Maxim Cournoyer Newsgroups: gmane.lisp.guile.bugs Subject: bug#41956: [PATCH] ice-9: exceptions: Properly format the error message. Date: Fri, 19 Jun 2020 17:33:02 -0400 Message-ID: <87eeqad9m9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="15126"; mail-complaints-to="usenet@ciao.gmane.io" To: 41956@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Fri Jun 19 23:34:11 2020 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jmOeI-0003uU-ME for guile-bugs@m.gmane-mx.org; Fri, 19 Jun 2020 23:34:10 +0200 Original-Received: from localhost ([::1]:44278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmOeH-0007Za-NT for guile-bugs@m.gmane-mx.org; Fri, 19 Jun 2020 17:34:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmOeA-0007VM-7i for bug-guile@gnu.org; Fri, 19 Jun 2020 17:34:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45424) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmOe9-0007q5-VC for bug-guile@gnu.org; Fri, 19 Jun 2020 17:34:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jmOe9-0007ui-Sh for bug-guile@gnu.org; Fri, 19 Jun 2020 17:34:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 19 Jun 2020 21:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41956 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.159260239130354 (code B ref -1); Fri, 19 Jun 2020 21:34:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Jun 2020 21:33:11 +0000 Original-Received: from localhost ([127.0.0.1]:56970 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jmOdL-0007tW-Ia for submit@debbugs.gnu.org; Fri, 19 Jun 2020 17:33:11 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:42948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jmOdH-0007tM-DT for submit@debbugs.gnu.org; Fri, 19 Jun 2020 17:33:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmOdH-0006s9-5z for bug-guile@gnu.org; Fri, 19 Jun 2020 17:33:07 -0400 Original-Received: from mail-qv1-xf44.google.com ([2607:f8b0:4864:20::f44]:43958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmOdF-0007lr-Gs for bug-guile@gnu.org; Fri, 19 Jun 2020 17:33:06 -0400 Original-Received: by mail-qv1-xf44.google.com with SMTP id dp10so5159289qvb.10 for ; Fri, 19 Jun 2020 14:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=1V/1WYzzNT3K6htb9CHbzxFZ+WBKiXSm9axPmCryHKY=; b=Brdj+M7jMtrc7nhwOJjte8DUGCvmD5jN0fl48UM7iw4UlLFgxTlOyNYQ4OB3Rqn7cR IYlwzRK7v0nmtzyuLWm/bLlanm8NJe7MvsGyQiljLkAqg0xyrfhEaTFODOvKCdKOF0hB 8dgI5X//VKzxdjAytrH+WuALjSEM14hgmf9ErQhMs9rMxjZTiRAA9NFZdwPN8/PSObai zovcB0QvlSisKVBLsI31rim+YG+/9Xu66glXhNMpCDMRXhX2MGuEBjXBLymtNREJayJZ x8kXyL5SPIFlhn1zNumGTzPbqM4aDIsCYahYZL6H8g1Bbp1dFXIJLclXA5BGLQVEIKP0 2h/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=1V/1WYzzNT3K6htb9CHbzxFZ+WBKiXSm9axPmCryHKY=; b=bME2LabQExPeIy5DSl5iDCO4fK8yG1f+gXrWRsrje8SX0Hcigl59ggR+rReKUlHY36 7LJPpCxsgukRcQ+YIaQBiAbLnDt8WhMvzM+0+ADu5oI8ksOa1Z1E9IUdpzl58IWD80iV a9UjPsNUr9z0vBdCIgmU8guMgpn+TFjRQA5k6s4yevcQIHLpVRkXr/8js+AfM+guVKfO /igOQxAoHHUne54Iynaxh0OIUk/XoIN1637MFnayXM6mT6D3MuF5fL+aIG749sgm4QS0 nt+T/5lyiTt1C8sI9b6SkeNBcjSrEqB5aIGczY0+wrd6b0tHUUlECbdIJRiUAHQTK8Q0 3sJg== X-Gm-Message-State: AOAM5333ZRN2vaZgd/ehxcuzuyW/tuRpaAxMNNuv4yBF5XpSJnU9AASp IGJEH2jrkv10qaVyB98KajOsCmMTBtAc7g== X-Google-Smtp-Source: ABdhPJwlunDQzZ6QYgksITBPncm7cNQfNx+tADhU/2+qq+SZBgN7pUCPwS1waHlqAek93zczzr6ScA== X-Received: by 2002:a05:6214:594:: with SMTP id bx20mr10716586qvb.131.1592602384296; Fri, 19 Jun 2020 14:33:04 -0700 (PDT) Original-Received: from hurd (dsl-158-72.b2b2c.ca. [66.158.158.72]) by smtp.gmail.com with ESMTPSA id n126sm7025129qke.15.2020.06.19.14.33.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 14:33:03 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::f44; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qv1-xf44.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9811 Archived-At: --=-=-= Content-Type: text/plain Hello, I had this problem in Guix where 'guix deploy my-config.scm' would unhelpfully report an error like: guix deploy: error: failed to deploy my-host: ~A: ~S Digging a bit, I could reproduce at the REPL with: --8<---------------cut here---------------start------------->8--- (guard (c ((message-condition? c) (format #t "error: ~a~%" (condition-message c)))) ;; This is what (canonicalize-path "/do/not/exist) ends up doing: (throw 'system-error "canonicalize-path" "~A" '("No such file or directory"))) --> error: ~A --8<---------------cut here---------------end--------------->8--- It seems our native -> srfi-34 style exception converter should populate the message field with a formatted message, given that's what happens to present errors as explained in libguile/error.c: When an error is reported,\n "these are replaced by formatting the corresponding members of\n" "@var{args}: @code{~A} (was @code{%s} in older versions of\n" "Guile) formats using @code{display} and @code{~S} I'm not sure about the second ~S that appeared in the Guix output; possibly the exception got re-thrown and suffered from a slightly different conversion problem? Anyway, the simple patch attached should fix the "~A" exception message. Thank you, Maxim --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ice-9-exceptions-Properly-format-the-error-message.patch >From adaa2f66fec7684e9e65491158afc5923613e3da Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Fri, 19 Jun 2020 14:30:05 -0400 Subject: [PATCH] ice-9: exceptions: Properly format the error message. Before this change, native exceptions such as system errors caught with srfi-34's `guard' would be converted to an exception with its message unhelpfully set to "~A". Thus, apply the message arguments to the message format to derive a human readable exception message. * module/ice-9/exceptions.scm (guile-common-exceptions): Format the message string using its arguments. --- module/ice-9/exceptions.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/ice-9/exceptions.scm b/module/ice-9/exceptions.scm index 143e7aa3e..c990790e9 100644 --- a/module/ice-9/exceptions.scm +++ b/module/ice-9/exceptions.scm @@ -189,7 +189,7 @@ ((subr msg margs . _) (make-exception (make-exception-with-origin subr) - (make-exception-with-message msg) + (make-exception-with-message (apply format #f msg margs)) (make-exception-with-irritants margs))) (_ (make-exception-with-irritants args))) args)) -- 2.26.2 --=-=-=--