Original Post
My current language project uses what could be best described as threads. I'm currently incorporating exception handling into the design, and I am wondering what is the consistent thing to do when a thread is not able to handle an exception: sure, it dies, but does it die a silent death, or rather kill the system as a whole? The language allows some (limited) manipulation of threads: the ability to cancel them, to determine if they are done, and so on. I would like to add the ability to check if the thread has encountered an unhandled exception, and have the code try to handle that exception in turn. My current approach would look like this:
// Create a first thread, runs at T = 1
event later = at (1.0) {
throw Exception.invalidOperation();
}
// Create a second thread, runs at T = 2
at (2.0) {
try (later)
catch (Exception.InvalidOperation ex)
Console.print("Caught an exception!\n");
}
My question are: 1° Would it make sense to add other possibilities for introspection into the reasons of failure, or is transmission of exceptions enough? 2° Once the event has been "tried", should this purge the exceptions, or should a second try throw the same exception again? 3° Using this approach, a thread which has been tied to an event will never stop the program. However, events are also used for other manipulations that might not include exception-handling. How can I make sure the exception will be heard at the OS level if nobody in the program checks for it? Also, a little bit unrelated 4°: should an Assert Failure throw an exception, or do something worse altogether?