The Right Approach to Exceptions

Andrei Alexandrescu SeeWebsiteForEmail at
Mon Feb 20 10:24:17 PST 2012

On 2/20/12 12:11 PM, dennis luehring wrote:
> Am 20.02.2012 17:36, schrieb Andrei Alexandrescu:
>> I understand this seems loose, but again, when you want to do custom
>> formatting or i18n this is the way to go. The job of rendering the
>> exception as a string must be outsourced (heh) outside the exception,
>> and Variant[string] is a simple mechanism to do so.
>> Andrei
> it is loose and Variant[string] is a simple mechanism for data
> transport, but evil in form of compile-time checks, the complete
> signature of your information is then (per se) only runtime-checked, how
> to prevent difference in the info[] filling and info[] usage over time?
> i just mistyped my key, removed a key, used a different, etc... multiply
> that by the amount of needed Exceptions and their info-key-variants ...
> hell on earth

This is not hell on earth, it is the classic type dilution when you need 
to abide to binary interfaces.

> in the end you will have a bunch of modules wich const-string-keys for
> the exception creation and rendering, and then i don't see any real
> difference to a specialize exception

No, you end up with centralized formatting facilities and smaller code.


More information about the Digitalmars-d mailing list