The Right Approach to Exceptions

deadalnix deadalnix at gmail.com
Mon Feb 20 13:02:56 PST 2012


Le 20/02/2012 21:49, Andrei Alexandrescu a écrit :
> On 2/20/12 1:32 PM, Juan Manuel Cabo wrote:
>> So, if your boss wants the URL of the request that was made
>> when the standard library threw you a FileNotFoundException,
>> you can do:
>>
>>
>> try {
>> ...
>> } catch (Exception ex) {
>> //Rethrow the exception with the added detail:
>> ex.details["custom_url"] = getenv("URI");
>> throw ex;
>> }
>
> That's a very interesting angle!
>
> Andrei
>
>

That is terrible. If ones begin to do this, then you cannot rely on what 
you'll find in the Exception infos.

And if people start to do that before any code is writen, It is very bad 
sign.


More information about the Digitalmars-d mailing list