hello all,

I asked JD if a proper solution to this would be to rethrow Exception as such:

} catch (Exception e) {
System.out.println("Exception found in GenbankSequenceDB -- getSequence");
System.out.println(e.toString());
ExceptionFound = true;
IOExceptionFound = true;
//create instance of Exception and throw it here so it gets passed back up the stack to
// the calling method....
Exception myException = new Exception("bad accession error");
throw myException;
      return null;
    }

the compiler won't complain if you're not throwing a checked exception. Or you could perhaps put a check for the boolean ExceptionFound in a finally clause and throw and exception from there if ExceptionFound == true; such as


} catch (Exception e) {
      System.out.println("Exception found in GenbankSequenceDB --
getSequence");
      System.out.println(e.toString());
      ExceptionFound = true;
      IOExceptionFound = true;
      return null;
    }
//always executed unless system.exit() is called;
finally
{
 // check for state of boolean ExceptionFound here
 if(ExceptionFound)
   {
       //error occured, throw an exception that will be handled further up
       //the stack
       throw new IlllegalAccessionException();
   }
}



just some thoughts.

thanks for your time,

Jess Vermont
Chicago, Il.

Universes of virtually unlimited complexity can be created in the form of computer programs. (Joseph Weizenbaum)




From: James Diggans <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [Biojava-l] Errors to STDOUT in BioJava?
Date: Sat, 20 Nov 2004 23:12:49 -0500


A design-related question: In GenbankSequenceDB's getSequence() method, the exception-handling code when catching an Exception thrown when a bad accession is used to search (returning nothing from Genbank) prints an error to STDOUT rather than passing the Exception up the chain like a good little Java method should:


...
} catch (Exception e) {
System.out.println("Exception found in GenbankSequenceDB -- getSequence");
System.out.println(e.toString());
ExceptionFound = true;
IOExceptionFound = true;
return null;
}


Is there a reason behind this? It results in an application that prints to STDOUT regardless of my wishes and also limits my ability to catch the Exception myself higher up in the stack to deal with it in an application-specific way. Just curious ... thanks.
-j


_______________________________________________
Biojava-l mailing list  -  [EMAIL PROTECTED]
http://biojava.org/mailman/listinfo/biojava-l

_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement


_______________________________________________
Biojava-l mailing list  -  [EMAIL PROTECTED]
http://biojava.org/mailman/listinfo/biojava-l

Reply via email to