From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 41956@debbugs.gnu.org
Subject: bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
Date: Fri, 19 Jun 2020 17:33:02 -0400 [thread overview]
Message-ID: <87eeqad9m9.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ice-9-exceptions-Properly-format-the-error-message.patch --]
[-- Type: text/x-patch, Size: 1248 bytes --]
From adaa2f66fec7684e9e65491158afc5923613e3da Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
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
next reply other threads:[~2020-06-19 21:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 21:33 Maxim Cournoyer [this message]
2020-06-20 5:46 ` bug#41956: [PATCH] ice-9: exceptions: Properly format the error message maxim.cournoyer
2020-06-20 18:33 ` Bengt Richter
2020-06-21 3:49 ` Maxim Cournoyer
2020-06-25 10:04 ` Ricardo Wurmus
2020-06-25 16:33 ` Bengt Richter
2020-06-28 4:25 ` Maxim Cournoyer
2020-06-28 18:23 ` Bengt Richter
2020-06-28 4:17 ` Maxim Cournoyer
2020-06-28 4:31 ` Ricardo Wurmus
2021-06-02 7:32 ` bug#41956: is this still current ? Adriano Peluso
2023-11-10 4:17 ` Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eeqad9m9.fsf@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=41956@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).