[Biojava-l] Nested Errors and Nested Exceptions
Matthew Pocock
mrp@sanger.ac.uk
Fri, 16 Mar 2001 10:51:52 +0000
Thomas Down wrote:
> On Fri, Mar 16, 2001 at 08:31:26AM +1300, Schreiber, Mark wrote:
>
>> Hi,
>>
>> Sorry if this has been covered before (I think it has) but when is it
>> reccommended that nested errors and nested exceptions be used. They seem to
>> be a useful "catch all", is this actually what they are for?
>
I tend to throw sub-classes of NestedException when something goes wrong
in an accepted way e.g. incorrect parameters or a process can't be
completed because of some failure in another module - incorrect ID
passed into sequenceDb or symbol not in an alphabet. I tend to throw
NestedError or one of its sub-classes when something has gone wrong that
there is no sensible way to recover from, or when the API says that
exceptions can be thrown, but the current context means that it should
be impossible (in which case I throw with an "Assertion Failure:"
message. A good example of the latter is when a setter that can raise
ChangeVetoException is called from within a constructor where no
listeners are registered to veto the change yet.
Basicaly, if the error is caused by another known source of error or by
incorrect use of the library, throw a sub-class of NestedException. If
it is meant to be impossible for something to happen unless BioJava has
incorrect implementation code then throw NestedError.
M
>
>
> All new exception types created for BioJava are sub-classes of
> NestedException (since it offers useful, general-purpose functionality).
>
</snip>
>
> Thomas
> _______________________________________________
> Biojava-l mailing list - Biojava-l@biojava.org
> http://biojava.org/mailman/listinfo/biojava-l