GNU bug report logs - #60799
Bogus 'Error while printing exception' message when raising srfi-35 exception

Previous Next

Package: guile;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Sat, 14 Jan 2023 01:31:02 UTC

Severity: normal

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60799 in the body.
You can then email your comments to 60799 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#60799; Package guile. (Sat, 14 Jan 2023 01:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sat, 14 Jan 2023 01:31:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: bug-guile <bug-guile <at> gnu.org>
Subject: Bogus 'Error while printing exception' message when raising srfi-35
 exception
Date: Fri, 13 Jan 2023 20:30:44 -0500
Hello Guile,

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:

--8<---------------cut here---------------start------------->8---
(use-modules (srfi srfi-35))

(define-condition-type &platform-not-found-error &error
  platform-not-found-error?)

(raise-exception &platform-not-found-error)
--8<---------------cut here---------------end--------------->8---

Produces:

--8<---------------cut here---------------start------------->8---
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.
--8<---------------cut here---------------end--------------->8---

This is probably not by design, right?

-- 
Thanks,
Maxim




Information forwarded to bug-guile <at> gnu.org:
bug#60799; Package guile. (Sat, 14 Jan 2023 07:33:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ricardo Wurmus <rekado <at> elephly.net>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 60799 <at> debbugs.gnu.org, bug-guile <at> gnu.org
Subject: Re: bug#60799: Bogus 'Error while printing exception' message when
 raising srfi-35 exception
Date: Sat, 14 Jan 2023 08:25:29 +0100
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”:

--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)))
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
ERROR:
  1. &platform-not-found-error
--8<---------------cut here---------------end--------------->8---

-- 
Ricardo




Information forwarded to bug-guile <at> gnu.org:
bug#60799; Package guile. (Sat, 14 Jan 2023 07:33:02 GMT) Full text and rfc822 format available.

Reply sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
You have taken responsibility. (Sat, 14 Jan 2023 14:54:01 GMT) Full text and rfc822 format available.

Notification sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
bug acknowledged by developer. (Sat, 14 Jan 2023 14:54:01 GMT) Full text and rfc822 format available.

Message #16 received at 60799-done <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ricardo Wurmus <rekado <at> elephly.net>
Cc: 60799-done <at> debbugs.gnu.org
Subject: Re: bug#60799: Bogus 'Error while printing exception' message when
 raising srfi-35 exception
Date: Sat, 14 Jan 2023 09:52:55 -0500
Hello Ricardo,

Ricardo Wurmus <rekado <at> 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




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 12 Feb 2023 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 74 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.