Exception Hierarchy [WAS: Re: Top 5]
Sean Kelly
sean at invisibleduck.org
Thu Oct 16 08:07:12 PDT 2008
Bruno Medeiros wrote:
>
> I agree there should be a distinction between recoverable exceptions
> (normal exceptions) and nonrecoverable exceptions (contract failures?).
> I agree that "Exception" should be the name for normal exceptions. The
> others could be named "Error" or "Failure".
> If we want the ability to catch these two separately, I don't see any
> other way other than having a third, top-level class, ie, a "Throwable",
> from which Exception and Error/Failure derive from.
This is exactly the design that was decided upon.
> But while one will certainly want to catch Exception's without catching
> Error's, I'm not 100% sure it would be useful to be able to easily catch
> an Error but not an Exception. Does anyone know of such a case?
Possibly for reporting purposes--catch an Error to test if a critical
error occurred, then re-throw. But I've never had a need for this
myself. One could argue, then, that these should all simply derive from
Throwable, but I think the logical grouping is useful for classification
purposes if nothing else.
Sean
More information about the Digitalmars-d
mailing list