The entire concept of an unending exception chain seems flawed to me, and having to carefully annotate or check everywhere is still error-prone for programmers.
It ought to be possible to create impenetrable exception boundaries, such as:
- A compilation unit / file.
- Something identified as a “library” (perhaps based on namespace).
- The program itself.
If I want my “library” to automatically trap all exceptions that I throw, I should be able to. I shouldn’t have to worry that entire programs may crash because of mistakes from exceptions. Similarly, a programmer should be able to say, ONCE (regardless of any functions added in the future), “trap all exceptions from code in this file using this function” and be done with it.
And, if the language had been designed with this kind of visibility into exceptions, one would also have more useful information at the time they are trapped. For instance, obviously exceptions propagating all the way to main() have very little useful context but knowing that an exception is trapped in a file scope would be huge for debugging.
It ought to be possible to create impenetrable exception boundaries, such as:
- A compilation unit / file.
- Something identified as a “library” (perhaps based on namespace).
- The program itself.
If I want my “library” to automatically trap all exceptions that I throw, I should be able to. I shouldn’t have to worry that entire programs may crash because of mistakes from exceptions. Similarly, a programmer should be able to say, ONCE (regardless of any functions added in the future), “trap all exceptions from code in this file using this function” and be done with it.
And, if the language had been designed with this kind of visibility into exceptions, one would also have more useful information at the time they are trapped. For instance, obviously exceptions propagating all the way to main() have very little useful context but knowing that an exception is trapped in a file scope would be huge for debugging.