public class ClosedIllegalStateException extends IllegalStateException
ClosedIllegalStateException is thrown to indicate that a method has been invoked on a
resource that is in an inappropriate state because it has been closed. For example, attempting to
read from a file that has already been closed.
This exception is a specialized version of IllegalStateException specifically for cases
where the illegal state is due to the resource being closed. This makes the exception more
semantically meaningful when dealing with closeable resources.
Here's a typical example of how ClosedIllegalStateException might be used:
public void readData() {
if (isClosed()) {
throw new ClosedIllegalStateException("Attempted to read from a closed resource.");
}
// ... read data ...
}
| Constructor and Description |
|---|
ClosedIllegalStateException(String s)
Constructs a
ClosedIllegalStateException with the specified detail message. |
ClosedIllegalStateException(String message,
Throwable cause)
Constructs a
ClosedIllegalStateException with the specified detail message and cause. |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic ClosedIllegalStateException(String s)
ClosedIllegalStateException with the specified detail message.
The detail message is meant to provide more information on why the exception was thrown.s - The detail message.public ClosedIllegalStateException(String message, Throwable cause)
ClosedIllegalStateException with the specified detail message and cause.
Note that the detail message associated with cause is not automatically
incorporated into this exception's detail message.
message - The detail message, which is saved for later retrieval by the Throwable.getMessage() method.cause - The cause (which is saved for later retrieval by the Throwable.getCause() method).
(A null value is permitted, and indicates that the cause is nonexistent or unknown.)Copyright © 2024. All rights reserved.