The Right Approach to Exceptions

Martin Nowak dawg at
Sat Feb 18 11:36:28 PST 2012

On Sat, 18 Feb 2012 20:24:16 +0100, deadalnix <deadalnix at> wrote:

> Le 18/02/2012 20:12, Martin Nowak a écrit :
>> Typed exception being used for local error recovery is about the same as
>> using
>> error codes but at a bigger expense. On the plus side exception can
>> carry more
>> specific error messages, which could be solved for error codes too.
> The problem with error code is that you have to handle all problems, or  
> none. A class hierarchy of exceptions allow you to handle some type of  
> errors, and not some others.
> At this point, I don't think we should think in terms of expansive or  
> not. Exception, as it is named, are for exceptionnal cases. If not, you  
> are probably using them the wrong way. And if it is exceptionnal, then  
> it seems reasoanble to sacrifice some CPU cycles to handle things  
> properly.

std.file.remove is a good example of how exceptions are used wrong.
It does not allow me to recover from an error, i.e. by changing the file  
Using a cenforce like translator is a much better approach IMO.

More information about the Digitalmars-d mailing list