public class SourcedInterruptedException extends InterruptedException implements ExceptionUtils.CustomStackTrace
InterruptedException
, which may include the source, see getInterruptSource()
.
This exception may be created directly where getCause()
returns null
,
or by propagating an existing InterruptedException
as returned by getCause()
.
Constructor and Description |
---|
SourcedInterruptedException(InterruptedException cause,
Throwable interruptSource) |
SourcedInterruptedException(String message,
InterruptedException cause,
Throwable interruptSource) |
Modifier and Type | Method and Description |
---|---|
InterruptedException |
getCause()
Returns the propagated
InterruptedException , i.e. |
Throwable |
getInterruptSource()
Returns the source of the
Thread.interrupt() call if known,
otherwise null is returned. |
void |
printCauseStack(PrintStream s,
String causeStr,
int causeIdx,
int stackDepth)
|
void |
printStackTrace(PrintStream s,
int causeDepth,
int stackDepth)
Custom
printStackTrace method, similar to Throwable#printStackTrace(PrintStream, int, int) . |
String |
toString() |
static InterruptedException |
wrap(InterruptedException ie)
Wraps the given
InterruptedException into a SourcedInterruptedException
if it is not yet of the desired type and
if the current thread if a InterruptSource , i.e. |
static InterruptedException |
wrap(InterruptedException ie,
InterruptSource source)
Wraps the given
InterruptedException into a SourcedInterruptedException
if it is not yet of the same type and if source is not null . |
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
public SourcedInterruptedException(String message, InterruptedException cause, Throwable interruptSource)
message
- mandatory message of this exceptioncause
- optional propagated causeinterruptSource
- optional propagated source of Thread.interrupt()
callpublic SourcedInterruptedException(InterruptedException cause, Throwable interruptSource)
cause
- mandatory propagated causeinterruptSource
- optional propagated source of Thread.interrupt()
callpublic static InterruptedException wrap(InterruptedException ie)
InterruptedException
into a SourcedInterruptedException
if it is not yet of the desired type and
if the current thread if a InterruptSource
, i.e. the source is known.
Otherwise the given InterruptedException
instance is returned.
In case method is creating a new wrapping instance,
InterruptSource.clearInterruptSource()
is being issued.
ie
- the to be wrapped InterruptedException
public static InterruptedException wrap(InterruptedException ie, InterruptSource source)
InterruptedException
into a SourcedInterruptedException
if it is not yet of the same type and if source
is not null
.
Otherwise the given InterruptedException
instance is returned.
In case method is creating a new wrapping instance,
InterruptSource.clearInterruptSource()
is being issued.
ie
- the to be wrapped InterruptedException
source
- the InterruptSource
public final Throwable getInterruptSource()
Thread.interrupt()
call if known,
otherwise null
is returned.public InterruptedException getCause()
InterruptedException
, i.e. the cause of this exception,
or null
if not applicable.
public final void printCauseStack(PrintStream s, String causeStr, int causeIdx, int stackDepth)
ExceptionUtils.CustomStackTrace
printCauseStack
in interface ExceptionUtils.CustomStackTrace
s
- output streamcauseStr
- the cause titlecauseIdx
- the cause index over all causes known by callerstackDepth
- the maximum depth for stack entries, or -1
for allpublic final void printStackTrace(PrintStream s, int causeDepth, int stackDepth)
ExceptionUtils.CustomStackTrace
printStackTrace
method, similar to Throwable#printStackTrace(PrintStream, int, int)
.printStackTrace
in interface ExceptionUtils.CustomStackTrace
s
- output streamcauseDepth
- the maximum depth for causes, or -1
for allstackDepth
- the maximum depth for stack entries, or -1
for all