Package com.mysql.cj.exceptions
Class AssertionFailedException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.mysql.cj.exceptions.CJException
com.mysql.cj.exceptions.AssertionFailedException
- All Implemented Interfaces:
java.io.Serializable
public class AssertionFailedException extends CJException
Assertions for empty code paths that should never be executed.
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AssertionFailedException(java.lang.Exception ex)Creates an AssertionFailedException for the given exception that should never have been thrown.AssertionFailedException(java.lang.String assertion)Creates an AssertionFailedException for the reason given. -
Method Summary
Modifier and Type Method Description static AssertionFailedExceptionshouldNotHappen(java.lang.Exception ex)Convenience method.static AssertionFailedExceptionshouldNotHappen(java.lang.String assertion)Create (and caller should subsequently throw) anAssertionFailedException.Methods inherited from class com.mysql.cj.exceptions.CJException
appendMessage, getMessage, getSQLState, getVendorCode, isTransient, setSQLState, setTransient, setVendorCode
-
Constructor Details
-
AssertionFailedException
public AssertionFailedException(java.lang.Exception ex)Creates an AssertionFailedException for the given exception that should never have been thrown.- Parameters:
ex- the exception that should never have been thrown.
-
AssertionFailedException
public AssertionFailedException(java.lang.String assertion)Creates an AssertionFailedException for the reason given.- Parameters:
assertion- a description of the assertion that failed
-
-
Method Details
-
shouldNotHappen
public static AssertionFailedException shouldNotHappen(java.lang.Exception ex) throws AssertionFailedExceptionConvenience method.- Parameters:
ex- the exception that should never have been thrown.- Returns:
AssertionFailedException- Throws:
AssertionFailedException- for the exception ex.
-
shouldNotHappen
public static AssertionFailedException shouldNotHappen(java.lang.String assertion) throws AssertionFailedExceptionCreate (and caller should subsequently throw) anAssertionFailedException.Typical use is as follows:
if (something == null) { throw AssertionFailedException.shouldNotHappen("Something cannot be null"); }- Parameters:
assertion- message- Returns:
- the exception. exception should be thrown by the caller to satisfy compiler checks for data-flow, etc
- Throws:
AssertionFailedException- if exception occurs
-