More exception classes into Phobos?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 23 17:25:35 PDT 2017


On 3/23/2017 1:34 PM, Jacob Carlborg wrote:
> A plain Exception is completely useless, it can just as well be an assertion
> instead. Because it's not possible to extract any information from the exception
> (except for trying to parse the message which is a bad idea) resulting in not
> being able to act on a thrown exception. Which then results in it being
> pointless to catch the exception in the first place.

It's a compelling point, and is the reason why there are many different 
exception types in Phobos.

But in my experience, if an error happens and it is local enough to be dealt 
with specifically, it is checked for directly without needing to go through an 
exception. If one is far enough removed from the source of the error that one is 
relying on exceptions, pretty much all one can do is the binary "it worked" or 
"it did not work". The "why it did not work" message is then logged or sent to 
the user, that is the only recovery necessary.

The fine grained Exception types is one of those things that sounds compelling 
but just doesn't seem to pay off in practice.


More information about the Digitalmars-d mailing list