[Biojava-dev] Sequence interface - exceptions

Mark Schreiber markjschreiber at gmail.com
Tue Jul 20 02:20:10 UTC 2010


I don't think it is a great idea to hide IO exceptions but you can
reduce the burden of them.

You can copy the Groovy model which handles a lot of the
try/catch/finally boiler plate code for you. Basically you make a
helper class with methods to perform common IO operations and which
will do it's very best to connect, read/write and clean up.

You can also think about what might actually cause an error. If you
are reading from a local disk cache where the file address is known
(such as a temp file) you can very nearly guarantee that the IO
operation will succeed. So much so that you could rethrow an IO
Exception as an error because there is very little that can be done
about it (other than improving the cache code or getting more reliable
hard-drives).

Reading a file from disk? The most likely problem is a incorrect file
name. Other problems can probably be turned into runtime exceptions
cause other problems are probably disk errors.

Reading from a URL, lots of things can go wrong here so you probably
need to expose all the possible exceptions.

Reading from SQL? Kind of depends on the expected DB availability and
latency. Also, if the query code (or JPA query) is coming from the
BioJava source then an error is appropriate (the developer can't do
much about the mistake). If the code is coming from the app developer
then you should notify them of SQL errors.

- Mark

On Mon, Jul 19, 2010 at 11:02 PM, Richard Holland
<holland at eaglegenomics.com> wrote:
>
> I often wonder what the best way of handling multiple possible internal exceptions is - particularly in cases like this when you've got HTTP and IO and many other types of exceptions which could be thrown.
>
> SequenceException maybe if there's something wrong with the sequence itself - but possibly otherwise a form of IOException may be more appropriate? Trouble is that then almost every BioJava3 method would throw it, as all of them potentially have IO exposure.
>
> I don't know. There must be experts on this in the list who can help!
>
> cheers,
> Richard
>
>
> On 19 Jul 2010, at 14:49, jake at researchtogether.com wrote:
>
> > Hi All,
> >
> > I've been drawing up a design for the work I have done on the NCBI SequenceReader and I've talked through some things with Scooter which I have put on the wiki at: http://www.biojava.org/wiki/BioJava3_NCBISequenceReader_Design#Design_Overview
> >
> > One thing I would like to throw open for discussion is the possibility of changing the Sequence interface so that the methods can throw a new exception - SequenceException.
> >
> > Any opinions? :)
> >
> > Cheers,
> > Jake
> > _______________________________________________
> > biojava-dev mailing list
> > biojava-dev at lists.open-bio.org
> > http://lists.open-bio.org/mailman/listinfo/biojava-dev
>
> --
> Richard Holland, BSc MBCS
> Operations and Delivery Director, Eagle Genomics Ltd
> T: +44 (0)1223 654481 ext 3 | E: holland at eaglegenomics.com
> http://www.eaglegenomics.com/
>
>
> _______________________________________________
> biojava-dev mailing list
> biojava-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-dev




More information about the biojava-dev mailing list