Exception vs. Error

Don Clugston dac at nospam.com.au
Thu Mar 29 07:45:47 PDT 2007


Stewart Gordon wrote:
> "Lionello Lunesu" <lio at lunesu.remove.com> wrote in message 
> news:eu87lp$2g7p$1 at digitalmars.com...
>> What's the difference between an Exception and an Error?
>>
>> I know that Exceptions are meant to be recoverable and Errors are 
>> non-recoverable, but this doesn't help me since
>> (1) Error is derived from Exception (so any catch(Exception) can 
>> _recover_ from an Error), and
>> (2) there are also many catch(Error) which seems that an Error is not 
>> quite that bad.
> 
> OUAT there was some discussion about tidying up the error/exception 
> hierarchy.  But "recoverable" depends on your POV.  What sense does it 
> make to set this in stone?  Some applications may be able to recover 
> from a given error, whereas others can't.
> 
> AISI there are three kinds of errors:
> (a) runtime checks in development builds, which are removed in release 
> builds (AssertError, SwitchError, ArrayBoundsError)
> (b) errors that stay in release builds, but which correctly-working 
> applications should never throw (e.g. FormatError)
> (c) errors that are generally beyond the programmer's control (e.g. file 
> system errors, out of memory)

Yes, I think the only sensible distinction is between 'this is 
DEFINITELY a bug', and 'this is a situation I don't know how to deal 
with', rather than 'recoverable'/'unrecoverable'.


More information about the Digitalmars-d-learn mailing list