001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.bio; 022 023/** 024 * A nestable biological exception. 025 * 026 * <p> 027 * In BioJava, checked exceptions are generally preferred to RuntimeExceptions, 028 * but RuntimeExceptions can be used as a fall-back if you are implementing 029 * an interface which doesn't support checked exceptions. If you do this, 030 * please document this clearly in the implementing class. 031 * </p> 032 * 033 * Occasionaly methods will document that the object they return may emit 034 * BioRuntimeExceptions. If you know what you are doing, you can catch these 035 * and do something sensible with them. An example would be an iterator() method 036 * that returns an Iterator where next() could fail due to a database connection 037 * flaking out. This could raise a BioRuntimeException wrapping the real cause. 038 * It would then not be unreasonable for the code calling next() to catch this 039 * BioRuntimeException and extract the cause. 040 * 041 * 042 * Occasionaly it is necisary to abuse the exception system by throwing BioError 043 * to get arround limitations in APIs that you do not control. For example, when 044 * implementing Iterator.next(), you may need to call a method that can fail. 045 * Catch the failure and throw it as a BioError. If you want people to handle 046 * this gracefully in their scripts, then document this behavior and hope they 047 * catch the error. 048 * 049 * @author Matthew Pocock 050 * @author Thomas Down 051 * 052 * 053 * 054 * 055 * @since 1.0 056 */ 057 058public class BioRuntimeException extends RuntimeException { 059 /** 060 * Create a new BioRuntimeException with a message. 061 * 062 * @param message the message 063 */ 064 public BioRuntimeException(String message) { 065 super(message); 066 } 067 068 069 /** 070 * Create a new BioRuntimeException with a cause. 071 * 072 * @param ex the Throwable that caused this BioRuntimeException 073 */ 074 public BioRuntimeException(Throwable ex) { 075 super(ex); 076 } 077 078 /** 079 * Create a new BioRuntimeException with a cause and a message. 080 * 081 * @param ex the Throwable that caused this BioRuntimeException 082 * @param message the message 083 * @deprecated use new BioRuntimeException(message, ex) instead 084 */ 085 public BioRuntimeException(Throwable ex, String message) { 086 this(message, ex); 087 } 088 089 /** 090 * Create a new BioRuntimeException with a cause and a message. 091 * 092 * @param message the message 093 * @param ex the Throwable that caused this BioRuntimeException 094 */ 095 public BioRuntimeException(String message, Throwable ex) { 096 super(message, ex); 097 } 098 099 /** 100 * Create a new BioRuntimeException. 101 */ 102 public BioRuntimeException() { 103 super(); 104 } 105}