The Right Approach to Exceptions
deadalnix at gmail.com
Sat Feb 18 11:24:16 PST 2012
Le 18/02/2012 20:12, Martin Nowak a écrit :
> Typed exception being used for local error recovery is about the same as
> 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.
More information about the Digitalmars-d