The Right Approach to Exceptions

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Feb 20 12:41:16 PST 2012


On 2/20/12 1:13 PM, Sean Kelly wrote:
> On Feb 20, 2012, at 9:55 AM, deadalnix wrote:
>>
>> And so variant is the way to go ?
>>
>> Clearly, this is a very strong arguement in favor of typed
>> Exception, that provide usefull information about what went wrong.
>> This is a safe approach.
>>
>> Because this Variant stuff is going to require massive ducktyping
>> of Exceptions, with all possible errors involved. The keys in the
>> Variant[string] will depend on the Exception the dev is facing.
>> This should be avoided and should warn us about the requirement of
>> typed Exceptions.
>
> I think its debatable whether a Variant[string] or string[string] is
> ideal here, but either way I think the point of the table is for
> localized error messages.  I wouldn't expect any data relevant for
> filtering the exception within the table.

Exactly.

The need for Variant instead of string is mainly to distinguish numeric 
info from string info when doing things like singular vs. plural or 
Arabic numeral rendering vs. textual ("one", "two" etc).


Andrei



More information about the Digitalmars-d mailing list