001package org.biojava.utils; 002 003/** 004 * An unchecked exception representing an Assertion failure. 005 * 006 * <p>Assertion failures should be raised when code finds itself in a state that 007 * should be impossible. It should not be raised in response to any predictable 008 * error condition. Assertion failures indicate that something has gone 009 * badly wrong, and that the assumptions under which library code has been 010 * developed are not holding.</p> 011 * 012 * <p>This extends {@link java.lang.AssertionError}, adding convenient 013 * constructors with messages and causes.</p> 014 * 015 * 016 * Your application may exit due to one of these being thrown. This usualy 017 * indicates that something is badly wrong with library code. It should never 018 * be raised in response to invalid arguments to methods, or incorrectly 019 * formatted data. It is not your fault. Report the error to the mailing list, 020 * or who ever else is responsible for the library code you are using. 021 * 022 * 023 * Under some rare circumstances, you may wish to catch assertion failures. For 024 * example, when debugging library code, or when the success or failure of an 025 * opperation is utterly inconsequential. Ignoring assertion failures 026 * out-of-hand is a sure-fire way to make your code buggy. 027 * 028 * 029 * Raise AssertionFailure in your code when something that should be impossible 030 * has happened. For example, if you have checked the alphabet of a symbol list 031 * you are working with, and somewhere further down an IllegalSymbolException 032 * is raised, then this is an assertion failure. 033 * 034 * @author Matthew Pocock 035 * @since 1.4 036 */ 037public class AssertionFailure 038extends AssertionError { 039 public AssertionFailure(String message) { 040 super(message); 041 } 042 043 public AssertionFailure(Throwable cause) { 044 initCause(cause); 045 } 046 047 public AssertionFailure(String message, Throwable cause) { 048 this(message); 049 initCause(cause); 050 } 051}