The Right Approach to Exceptions
svv1999 at hotmail.com
Sat Feb 18 17:17:03 PST 2012
Andrei Alexandrescu wrote:
> why are various error deserving of their own types.
If an error can be forseen and one and only one solution is known and
computable, then the only throwable exception is "not yet implemented"
In all other cases the human operator must be informed about the cause,
which can be done by output as the tutorials suggest.
If at least one algorithm is coded to deal with the error the human
decision is required to decide whether this one and only or which of
several algorithms should be used. It might be an advantage to have the
code of those algorithms closely linked and separated from the rest of
the possibly partly failing machine.
Using types in an already failing system is based on 3), the fact that
types are unique in the hole system and the hope, that not all that can
fail will indeed fail.
More information about the Digitalmars-d