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:
  Serializable

    public class AssertionFailedException
    extends CJException

Assertions for empty code paths that should never be executed.

See Also:
  Serialized Form

### Field Summary

Fields
`private static long` `serialVersionUID`

### Fields inherited from class com.mysql.cj.exceptions.CJException

`exceptionMessage`

### Constructor Summary

Constructors
Constructor and Description
`AssertionFailedException(Exception ex)` Creates an AssertionFailedException for the given exception that should never have been thrown.
`AssertionFailedException(String assertion)` Creates an AssertionFailedException for the reason given.

### Method Summary

All Methods Static Methods Concrete Methods
`static AssertionFailedException` `shouldNotHappen(Exception ex)` Convenience method.
`static AssertionFailedException` `shouldNotHappen(String assertion)` Create (and caller should subsequently throw) an `AssertionFailedException`.

### Methods inherited from class com.mysql.cj.exceptions.CJException

`appendMessage, getMessage, getSQLState, getVendorCode, isTransient, setSQLState, setTransient, setVendorCode`

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### serialVersionUID

    private static final long serialVersionUID

See Also:
  Constant Field Values

### Constructor Detail

#### AssertionFailedException

    public AssertionFailedException(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(String assertion)

Creates an AssertionFailedException for the reason given.

Parameters:
  `assertion` - a description of the assertion that failed

### Method Detail

#### shouldNotHappen

    public static AssertionFailedException shouldNotHappen(Exception ex)
                                                    throws AssertionFailedException

Convenience method.

Parameters:
  `ex` - the exception that should never have been thrown.
Returns:
  `AssertionFailedException`
Throws:
  `AssertionFailedException` - for the exception ex.

#### shouldNotHappen

    public static AssertionFailedException shouldNotHappen(String assertion)
                                                    throws AssertionFailedException

Create (and caller should subsequently throw) an `AssertionFailedException`.

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

Copyright © 2016, 2024, Oracle and/or its affiliates.