From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: 41956@debbugs.gnu.org
Subject: bug#41956: [PATCH] ice-9: exceptions: Properly format the error message.
Date: Sun, 28 Jun 2020 00:17:04 -0400 [thread overview]
Message-ID: <87y2o7lt8f.fsf@gmail.com> (raw)
In-Reply-To: <87bll7qx5g.fsf@elephly.net> (Ricardo Wurmus's message of "Thu, 25 Jun 2020 12:04:27 +0200")
Hello Ricardo!
Ricardo Wurmus <rekado@elephly.net> writes:
> Hi Maxim,
>
> here’s what I did in the REPL:
>
> scheme@(guile-user)> ,m (ice-9 exceptions)
> scheme@(ice-9 exceptions)> (define (my/guile-system-error-converter key args)
> (apply (case-lambda
> ((subr msg-args msg errno . rest)
> ;; XXX TODO we should return a more specific error
> ;; (usually an I/O error) as expected by R6RS programs.
> ;; Unfortunately this often requires the 'filename' (or
> ;; other?) which is not currently provided by the native
> ;; Guile exceptions.
> (make-exception
> (make-external-error)
> (make-exception-with-origin subr)
> (apply make-exception-with-message msg)
> (make-exception-with-irritants msg-args)))
> (_ (guile-external-error-converter key args)))
> args))
> scheme@(ice-9 exceptions)> (set! guile-exception-converters (acons 'system-error my/guile-system-error-converter guile-exception-converters))
> scheme@(ice-9 exceptions)> ,m (guile-user)
> scheme@(guile-user)> (guard (c ((message-condition? c)
> (format #t "message: ~a~%" (condition-message c))))
> (canonicalize-path "/doesntexist"))
> message: No such file or directory
> $11 = #t
> scheme@(guile-user)>
I've tested that this indeed works, although I don't quite understand
how?
This brings embeds the definition of `guile-common-exceptions' into
`guile-system-error-converter', with a single change:
(make-exception-with-message msg) --> (apply make-exception-with-message
msg msg-args)
What is the magic I fail to see?
Is this fix proper to be merged into the original
guile-common-exceptions procedure?
Thank you!
Maxim
next prev parent reply other threads:[~2020-06-28 4:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 21:33 bug#41956: [PATCH] ice-9: exceptions: Properly format the error message Maxim Cournoyer
2020-06-20 5:46 ` 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 [this message]
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=87y2o7lt8f.fsf@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=41956@debbugs.gnu.org \
--cc=rekado@elephly.net \
/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).