Hello - Exceptions that extend RuntimeException don't have to be caught. This was a contraversial decision by the Java designers so they could make things like NullPointerException. If you think of all the times you could throw a null pointer exception you would need a hell of a lot of try catch statements (one for everytime you pass an object reference). Classes that extend RuntimeException are supposed to indicate failures due to bad programming practice. They shouldn't really occur in a well made program. You can catch them, you just have to know when they might be thrown. You should only try to catch them if you can recover sensibly though so most times you wouldn't bother unless you have a system that needs to run 24/7 without crashing. BioRuntimeException is one of these but hardly used in the API.
The other type of Throwable is that doesn't need to be caught is Error (BioError is one of these, also rarely used). Errors are generally considered to be unrecoverable. You generally log them, shutdown as gracefully as possible and call tech support. BioException is much more common. This extends good old Exception and must be declared and caught. It is used all over. So I'm not sure what the problem is. If you call DNATools.createDNA and throw some rubbish at it you will probably get something like IllegalSymbolException (subclass of BioException). You can catch this. Without seeing the program or stack trace all I can think of is that some bug is causing an Error to be thrown somewhere. The only other possibility is that you have two catch statements that conflict. Eg if you catch BioException and exit before you catch IllegalSymbolException then you won't reach this. Although your compiler should complain about this so it seems unlikely. Can you send the source? or that exception stack? - Mark "Richard HOLLAND" <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 12/17/2004 12:42 PM To: <[EMAIL PROTECTED]> cc: (bcc: Mark Schreiber/GP/Novartis) Subject: [Biojava-l] Exception handling Hi all, I'd like to be able to catch exceptions and handle them but it seems that many BioJava exceptions are sub-classes of the system kill everything no matter what exception, which makes them uncatchable. For instance if I try and load a junk sequence using DNATools, I get an exception quite rightly complaining about the alphabet, but even though I try-catch the code that parses this junk sequence (for Exception), the program quits completely without my exception handler or any further code being called. Is this deliberate? Surely it would be nicer to allow these exceptions to be caught? I have noticed that many routines in the BioJava source code throw BioException (or a name similar to that, can't remember...), yet do not declare it in their method signatures. This could be why. It'd be much nicer to actually declare you are going to throw an exception, what type it is likely to be, then behave nicely instead of killing the whole app. cheers, Richard Richard Holland Bioinformatics Specialist GIS extension 8199 --------------------------------------------- This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notify us immediately. Please do not copy or use it for any purpose, or disclose its content to any other person. Thank you. --------------------------------------------- _______________________________________________ Biojava-l mailing list - [EMAIL PROTECTED] http://biojava.org/mailman/listinfo/biojava-l _______________________________________________ Biojava-l mailing list - [EMAIL PROTECTED] http://biojava.org/mailman/listinfo/biojava-l