The Right Approach to Exceptions
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Feb 20 15:30:22 PST 2012
On 2/20/12 4:57 PM, H. S. Teoh wrote:
> So I think what we should have is *both* data stored in fields in
> Exception subclasses, and some kind of way to attach auxilliary data to
> the exception. Say with Variant[string], or whatever way you prefer.
>
> But Variant[string] should not be used for *everything*. That only leads
> to problems. But then, it limits the usefulness of Variant[string],
> because then you can't just pass it to the i18n formatter, since now
> some fields are static but they may need to be part of the formatted
> message.
Great. I'll plant the interface and submit it for destruction.
> So we haven't really solved anything, we just added a new feature to
> Exception which I'm not sure how useful it is. Do you have actual use
> cases that requires adding data to exceptions? Without concrete examples
> we're just arguing about hypotheticals.
I'm seeing plenty of that in our code base at work. They use exception
wrapping in conjunction with a fair amount of contortions because the
Variant[string] approach has not been designed.
Andrei
More information about the Digitalmars-d
mailing list