The Right Approach to Exceptions

Jonathan M Davis jmdavisProg at
Mon Feb 20 18:31:20 PST 2012

On Monday, February 20, 2012 17:23:42 Andrei Alexandrescu wrote:
> On 2/20/12 4:44 PM, Juan Manuel Cabo wrote:
> > HAhaha, it sometimes feel as though people are afraid that the
> > Variant[string] idea is to never use plain old variables and never use
> > exception subclasses. :-)
> > 
> > On the contrary, the idea is so that plain old variables and exception
> > subclasses can be created for the right reasons, and to remove cases
> > where they need to be created for the wrong reasons.
> Yah, I think there's a lot of confusion and consequent apprehension
> regarding this. Thanks for attempting to clarify things.

I think that as long as it makes sense to catch an exception and handle it 
based on a new type, any information associated with that exception should be 
member variables in that exception. But if you have extra information which 
could be useful but where you wouldn't really want to catch a new type, then 
it makes some sense to use the hashtable. However, I don't recall ever having 
personally run into a situation where that sort of need arose.

- Jonathan M Davis

More information about the Digitalmars-d mailing list