Class UnexpectedExceptionError

java.lang.Object
java.lang.Throwable
java.lang.Error
java.lang.AssertionError
org.tquadrat.foundation.exception.UnexpectedExceptionError
All Implemented Interfaces:
Serializable

@ClassVersion(sourceVersion="$Id: UnexpectedExceptionError.java 1293 2026-10-16 13:12:15Z tquadrat $") @API(status=DEPRECATED, since="0.0.5") @Deprecated(since="0.25.15", forRemoval=true) final class UnexpectedExceptionError extends AssertionError
Deprecated, for removal: This API element is subject to removal in a future version.
Basically, this exception was renamed to UnlikelyExceptionError because that name matches the intention better than the original name.

This implementation of Error should be thrown in all cases where an unexpected exception was caught. Unlike an ImpossibleExceptionError, the exception is possible, but not expected – probably because the programmer has taken (at least thought to have …) appropriate precautions against its occurrence. An example for this could be an implementation of clone() for a particular class: with implementing that method (and declaring the interface Cloneable …), instances of that class do support cloning and therefore that exception should not be thrown. Unfortunately, changes somewhere else in the source might prevent one of the attributes of the respective class from being cloned, so that exception could be thrown again …

Another example could be this code sequence:

…
final var file = new File( … );
if( file.exists() )
{
    try( final var inputStream = new FileInputStream( file ) )
    {
        …
    }
    catch( final FileNotFoundException e )
    {
        throw new UnexpectedExceptionError( e );
    }
}

Although the code checked that the file exists, it could have vanished unexpectedly just before it was opened.

Author:
Thomas Thrien (thomas.thrien@tquadrat.org)
Version:
$Id: UnexpectedExceptionError.java 1293 2026-10-16 13:12:15Z tquadrat $
Since:
0.0.5
UML Diagram
UML Diagram for "org.tquadrat.foundation.exception.UnexpectedExceptionError"⁠

UML Diagram for "org.tquadrat.foundation.exception.UnexpectedExceptionError"

UML Diagram for "org.tquadrat.foundation.exception.UnexpectedExceptionError"⁠
  • Field Details

  • Constructor Details

    • UnexpectedExceptionError

      Deprecated, for removal: This API element is subject to removal in a future version.

      Creates a new instance of UnexpectedExceptionError. The message is a constant, only the causing exception can be given.

      Parameters:
      cause - The causing exception.
    • UnexpectedExceptionError

      public UnexpectedExceptionError(String message, Throwable cause)
      Deprecated, for removal: This API element is subject to removal in a future version.

      Creates a new instance of UnexpectedExceptionError. This constructor should be used in cases where an enhanced message is useful or necessary.

      Parameters:
      message - The message for the error.
      cause - The causing exception.