Class UnexpectedExceptionError
- All Implemented Interfaces:
Serializable
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"
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringDeprecated, for removal: This API element is subject to removal in a future version.The message for this exception. -
Constructor Summary
ConstructorsConstructorDescriptionUnexpectedExceptionError(String message, Throwable cause) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new instance ofUnexpectedExceptionError.Deprecated, for removal: This API element is subject to removal in a future version.Creates a new instance ofUnexpectedExceptionError. -
Method Summary
Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
MSG_UnexpectedException
Deprecated, for removal: This API element is subject to removal in a future version.The message for this exception.- See Also:
-
-
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
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.
-

UnlikelyExceptionErrorbecause that name matches the intention better than the original name.