@Immutable public class ControlFlowException extends Error
Note that although the name of this class suggests that it's an exception
type, it deliberately subclasses Error
in order to prevent its
instances from being accidentally catched as an ordinary Exception
.
This is done to particularly protect against code which catches and
erroneously suppresses any RuntimeException
instead of propagating
them to the caller.
As a general recommendation, if you need to ensure resource cleanup
regardless of any Throwable
then please place the cleanup code in a
finally-block like this:
Resource resource = new Resource();
try {
// May terminate with any Throwable, including ControlFlowException.
resource.use();
} finally {
resource.cleanup(); // finally-block ensures cleanup
}
Constructor and Description |
---|
ControlFlowException() |
ControlFlowException(boolean enableSuppression) |
ControlFlowException(Throwable cause) |
ControlFlowException(Throwable cause,
boolean enableSuppression) |
Modifier and Type | Method and Description |
---|---|
static boolean |
isTraceable()
Returns
true if and only if a control flow exception should have
a full stack trace instead of an empty stack trace. |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public ControlFlowException()
public ControlFlowException(boolean enableSuppression)
public ControlFlowException(@CheckForNull Throwable cause)
public ControlFlowException(@CheckForNull Throwable cause, boolean enableSuppression)
public static boolean isTraceable()
true
if and only if a control flow exception should have
a full stack trace instead of an empty stack trace.
If and only if the system property with the key string
net.java.truecommons.shed.ControlFlowException.traceable
is set to true
(whereby case is ignored), then instances of this
class will have a regular stack trace, otherwise their stack trace will
be empty.
Note that this should be set to true
for debugging purposes only.true
if and only if a control flow exception should have
a full stack trace instead of an empty stack trace.Copyright © 2012–2015 Schlichtherle IT Services. All rights reserved.