[Biojava-dev] DNATools.createDNA and IllegalSymbolException

Thomas Down thomas at derkholm.net
Wed May 28 10:04:41 EDT 2003


Once upon a time, Dirk Habighorst wrote:
> Hi,
> 
> The IllegalSystemException cannot be thrown here since it is handled in the 
> catch block. Is it the desired behaviour to get a BioError here? I would 
> prefer to have the choice of catching the IllegalSymbolException here.
> 
> --- snip ---
>  public static SymbolList createDNA(String dna)
>  throws IllegalSymbolException {
>    try {
>      SymbolTokenization p = getDNA().getTokenization("token");
>      return new SimpleSymbolList(p, dna);
>    } catch (BioException se) {
>      throw new BioError(se, "Something has gone badly wrong with DNA");
>    }
>  }
> --- snip ---

That's a good point.  How about:


public static SymbolList createDNA(String dna)
   throws IllegalSymbolException 
{
   try {
      SymbolTokenization p = getDNA().getTokenization("token");
      return new SimpleSymbolList(p, dna);
   } catch (IllegalSymbolException ise) {
      throw ise;
   } catch (BioException se) {
      throw new BioError(se, "Something has gone badly wrong with DNA");
   }
}

So IllegalSymbolExceptions can still be caught, but other
types of exception (which probably *do* mean something has
gone wrong internally) still raise a BioError.

If nobody has any objections, I'll apply that...

     Thomas.


More information about the biojava-dev mailing list