guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exception handler installed when handling a continuable exception


From: Vivien Kraus
Subject: Exception handler installed when handling a continuable exception
Date: Mon, 09 Aug 2021 09:26:38 +0200

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]