Results, Exceptions, and Custom Effects #452
-
Hi, I've been playing around with Koka a lot recently, and it's been great, if a bit mindbending at times! I'm writing a basic AST-walking interpreter, and I've got some stuff in there that's fallible — for example, missing functions, or calling things with the wrong number of arguments. Currently, I make a lot of use of the Dealing with these What sort of patterns are recommended, or at least have been tried out so far? Is it expected that people will mostly stick to the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
For domains specific exceptions it is often appropriate to create your own exception effect which allows you to ensure that you are catching only your kind of exception where you want to handle it, and not any other types of exceptions, as well as any other domain-specific exit behaviors. However, that being said, you'll notice that throw takes an optional argument
To define your own variants of an
This creates two new constructors for exception-info. You'll notice two |
Beta Was this translation helpful? Give feedback.
For domains specific exceptions it is often appropriate to create your own exception effect which allows you to ensure that you are catching only your kind of exception where you want to handle it, and not any other types of exceptions, as well as any other domain-specific exit behaviors.
However, that being said, you'll notice that throw takes an optional argument
exception-info
, of which there are a few variants (and you'll notice it is anopen type
).