From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: 60799-done@debbugs.gnu.org
Subject: bug#60799: Bogus 'Error while printing exception' message when raising srfi-35 exception
Date: Sat, 14 Jan 2023 09:52:55 -0500 [thread overview]
Message-ID: <87a62ldv7c.fsf@gmail.com> (raw)
In-Reply-To: <87sfgdk1w7.fsf@elephly.net> (Ricardo Wurmus's message of "Sat, 14 Jan 2023 08:25:29 +0100")
Hello Ricardo,
Ricardo Wurmus <rekado@elephly.net> writes:
> Hi Maxim,
>
>> When raising a srfi-35 defined exception type like in the following, a
>> generic (and unhelpful) "Error while printing exception" message is
>> shown, with not even the exception type mentioned:
>>
>> (use-modules (srfi srfi-35))
>>
>> (define-condition-type &platform-not-found-error &error
>> platform-not-found-error?)
>>
>> (raise-exception &platform-not-found-error)
>>
>>
>> Produces:
>>
>> Backtrace:
>> In ice-9/boot-9.scm:
>> 1752:10 5 (with-exception-handler _ _ #:unwind? _ # _)
>> In unknown file:
>> 4 (apply-smob/0 #<thunk 7f236157a2e0>)
>> In ice-9/boot-9.scm:
>> 724:2 3 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
>> In ice-9/eval.scm:
>> 619:8 2 (_ #(#(#<directory (guile-user) 7f2361580c80>)))
>> In ice-9/boot-9.scm:
>> 2836:4 1 (save-module-excursion _)
>> 4388:12 0 (_)
>>
>> ice-9/boot-9.scm:4388:12: Error while printing exception.
>>
>> This is probably not by design, right?
>
> Perhaps not, but conditions are expected to be raised with “raise”:
>
> (use-modules (srfi srfi-34) (srfi srfi-35))
>
> (define-condition-type &platform-not-found-error &error
> platform-not-found-error?)
>
> (raise (condition (&platform-not-found-error)))
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> ERROR:
> 1. &platform-not-found-error
Thanks for pointing that. The above with 'raise' doesn't produce the
same output for my Guile 3.0.8:
--8<---------------cut here---------------start------------->8---
(use-modules (srfi srfi-35))
(define-condition-type &platform-not-found-error &error
platform-not-found-error?)
(raise (condition (&platform-not-found-error)))
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Wrong type (expecting exact integer): #<&platform-not-found-error>
--8<---------------cut here---------------end--------------->8---
Using 'raise-exception' instead of 'raise' fixes it for me:
--8<---------------cut here---------------start------------->8---
(raise-exception (condition (&platform-not-found-error)))
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
ERROR:
1. &platform-not-found-error
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
--8<---------------cut here---------------end--------------->8---
So my initial issue was attempting to raise on a type rather than an
object (which works both ways in other languages such as Python).
If I also import srfi-34, then it works as expected:
--8<---------------cut here---------------start------------->8---
(use-modules (srfi srfi-34) (srfi srfi-35))
(define-condition-type &platform-not-found-error &error
platform-not-found-error?)
(raise (condition (&platform-not-found-error)))
--8<---------------cut here---------------end--------------->8---
So my original confusing was that there exists a 'raise' procedure in
Guile, which has nothing to do with exceptions (it's used to send a
signal to the current process).
What I'll take from this is to use exclusively 'raise-exception', which
is not subject to the above srfi-34 vs builtin raise confusion.
Closing, thanks for helping me untangle things!
--
Thanks,
Maxim
prev parent reply other threads:[~2023-01-14 14:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-14 1:30 bug#60799: Bogus 'Error while printing exception' message when raising srfi-35 exception Maxim Cournoyer
2023-01-14 7:25 ` Ricardo Wurmus
2023-01-14 14:52 ` Maxim Cournoyer [this message]
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=87a62ldv7c.fsf@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=60799-done@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).