Comparing Exceptions and Errors
Ali Çehreli
acehreli at yahoo.com
Sat Jun 4 00:44:50 UTC 2022
On 6/3/22 16:40, Steven Schveighoffer wrote:
> https://www.schveiguy.com/blog/2022/05/comparing-exceptions-and-errors-in-d/
Cool! I didn't know catching Errors behaves specially in unittest blocks
and contracts.
One feedback I have is about non-main threads. Although everybody agrees
that Errors should not be caught, the main thread does so and prints the
useful output that you show in the article.
If the main thread is allowed to do that, we should do as much (or less)
in non-main threads as well. Otherwise, threads disappear without a trace.
If we are paranoid and want to do as little as possible, at least we
should attempt to copy a string literal to stderr. Something like
"Thread exiting with Error." And exit(1) right after that.
But all of that is wishful programming because if the program is in an
illegal state, should we attempt to report it? If we should not,
shouldn't the main thread should not either? (Sorry, non-native Inglish
speaker here. :p)
Ali
More information about the Digitalmars-d-learn
mailing list