unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Exception handler installed when handling a continuable exception
@ 2021-08-25 19:08 Maxime Devos
  2021-09-30 21:39 ` Vivien Kraus via General Guile related discussions
  0 siblings, 1 reply; 3+ messages in thread
From: Maxime Devos @ 2021-08-25 19:08 UTC (permalink / raw)
  To: vivien, guile-user

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

Hi,

This also happens without #:continuable?.
Here's a simpler test case:

(with-exception-handler
  (lambda (exn)
    (catch #t
      (lambda () (error "to be caught"))
      (lambda e (pk 'caught! e))))
  (lambda () (error "oops")))
---> In procedure raise-exceptiont: to be caught

I don't know if this is a bug.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Exception handler installed when handling a continuable exception
  2021-08-25 19:08 Exception handler installed when handling a continuable exception Maxime Devos
@ 2021-09-30 21:39 ` Vivien Kraus via General Guile related discussions
  0 siblings, 0 replies; 3+ messages in thread
From: Vivien Kraus via General Guile related discussions @ 2021-09-30 21:39 UTC (permalink / raw)
  To: Maxime Devos, guile-user

Hello, I finally figured it out:

Le mercredi 25 août 2021 à 21:08 +0200, Maxime Devos a écrit :
> This also happens without #:continuable?.
> Here's a simpler test case:
> 
> (with-exception-handler
>   (lambda (exn)
>     (catch #t
>       (lambda () (error "to be caught"))
>       (lambda e (pk 'caught! e))))
>   (lambda () (error "oops")))
> ---> In procedure raise-exceptiont: to be caught
> 
> I don't know if this is a bug.
It is not, it was in the documentation the whole time. The effective
handler is the outmost handler, unless #:unwind? is #t. I was tricked
by the obscure scheme jargon, but this works as expected:

(with-exception-handler
  (lambda (exn)
    (catch #t
      (lambda () (error "to be caught"))
      (lambda e (pk 'caught! e))))
  (lambda () (error "oops"))
  #:unwind? #t)




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Exception handler installed when handling a continuable exception
@ 2021-08-09  7:26 Vivien Kraus via General Guile related discussions
  0 siblings, 0 replies; 3+ messages in thread
From: Vivien Kraus via General Guile related discussions @ 2021-08-09  7:26 UTC (permalink / raw)
  To: guile-user


Dear guile users,

When an exception is raised with #:continuable?, and when the handler
returns a value, then the program continues.

This is why this program prints "hello":

(use-modules (ice-9 exceptions))

(with-exception-handler
    (lambda (exn)
      ;; We want to return "hello"
      "hello\n")
  (lambda ()
    (format (current-error-port)
            (raise-exception (make-exception-with-message "What should I say?")
                             #:continuable? #t))))

Now, in the handler, I may want to handle other kinds of exceptions:

(use-modules (ice-9 exceptions))

(with-exception-handler
    (lambda (exn)
      ;; We want to return "hello"
      (false-if-exception
       ;; Shouldn’t this error be ignored?
       (error "messing around"))
      "hello\n")
  (lambda ()
    (format (current-error-port)
            (raise-exception (make-exception-with-message "What should I say?")
                             #:continuable? #t))))

Is this a bug?

Best regards,

Vivien



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-30 21:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 19:08 Exception handler installed when handling a continuable exception Maxime Devos
2021-09-30 21:39 ` Vivien Kraus via General Guile related discussions
  -- strict thread matches above, loose matches on Subject: below --
2021-08-09  7:26 Vivien Kraus via General Guile related discussions

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).