[Top][All Lists]

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

Exception handling - symbol for encoding exception type?

From: Zelphir Kaltstahl
Subject: Exception handling - symbol for encoding exception type?
Date: Tue, 8 Mar 2022 17:11:26 +0000

Hello Guile users!

I have a question about exception handling.

Lets say I have some code raising some exception:

(import (ice-9 exceptions))

(define something-causing-an-exception
  (λ ()
      (make-exception-with-message "Some error message.")
      (make-exception-with-irritants (list whatever is responsible for causing 
an error))
      (make-exception-with-origin 'name-of-procedure)))))

    (λ (exception)
      ;; handling the exception
  (λ ()
  #:unwind? #t)

I can see a hierarchy of exception types:

|- &warning
|- &message
|- &irritants
|- &origin
\- &error
   |- &external-error
   \- &programming-error
      |- &assertion-failure
      |- &non-continuable
      |- &implementation-restriction
      |- &lexical
      |- &syntax
      \- &undefined-variable

Is the idea, that one should rely merely on the existing
exception types, which are:

+ assertion-failure
+ non-continuable
+ implementation-restriction
+ lexical
+ syntax
+ undefined-variable

and that one should not try to create additional types? Or
is the idea to encode more specifics into the &message?

I guess I am looking for a way to specify a symbol and
later, when an exception happens, check for a symbol, to
know what the reason for the exception is, instead of
searching around in a &message string, which feels a bit

I think in some other languages this would be encoded in
the type or class or the exception itself. One would catch
only exceptions of a specific type. This is a convention
inside the code, which does not necessarily spread to other
programs or code bases.

Best regards,


reply via email to

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