The Right Approach to Exceptions

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Feb 20 15:28:37 PST 2012


On 2/20/12 4:46 PM, foobar wrote:
> On Monday, 20 February 2012 at 21:02:21 UTC, Andrei Alexandrescu wrote:
>> On 2/20/12 2:01 PM, foobar wrote:
>>> Seconded. Reflection seems a much better solution for this.
>>
>> Absolutely.
>>
>>> The i18n table would map (exception type) -> (language, format string)
>>> and the i18n formatter would use reflection to map field values to the
>>> format string.
>>> a format string would be e.g. "File {filename} not found" and the
>>> formatter would replace {filename} with e.class.getField("filename").
>>>
>>> This does not require any modifications to the exception mechanism.
>>
>> Yah, but the reflection engine would have to present RTTI in a uniform
>> manner... such as, Variant[string]. Bane of my life: I'm always right
>> :o).
>>
>>
>> Andrei
>
> Unfortunately you aren't :)

Esprit d'escalier! "Bane of my life: nobody admits I'm always right."

Damn I wish I'd come up with that a minute ago before submitting.


Andrei



More information about the Digitalmars-d mailing list