Package com.jogamp.common.util
Class SourcedInterruptedException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.InterruptedException
-
- com.jogamp.common.util.SourcedInterruptedException
-
- All Implemented Interfaces:
ExceptionUtils.CustomStackTrace
,Serializable
public class SourcedInterruptedException extends InterruptedException implements ExceptionUtils.CustomStackTrace
InterruptedException
, which may include the source, seegetInterruptSource()
.This exception may be created directly where
getCause()
returnsnull
, or by propagating an existingInterruptedException
as returned bygetCause()
.- Since:
- 2.3.2
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SourcedInterruptedException(InterruptedException cause, Throwable interruptSource)
SourcedInterruptedException(String message, InterruptedException cause, Throwable interruptSource)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description InterruptedException
getCause()
Returns the propagatedInterruptedException
, i.e.Throwable
getInterruptSource()
Returns the source of theThread.interrupt()
call if known, otherwisenull
is returned.void
printCauseStack(PrintStream s, String causeStr, int causeIdx, int stackDepth)
void
printStackTrace(PrintStream s, int causeDepth, int stackDepth)
CustomprintStackTrace
method, similar toThrowable#printStackTrace(PrintStream, int, int)
.String
toString()
static InterruptedException
wrap(InterruptedException ie)
Wraps the givenInterruptedException
into aSourcedInterruptedException
if it is not yet of the desired type and if the current thread if aInterruptSource
, i.e.static InterruptedException
wrap(InterruptedException ie, InterruptSource source)
Wraps the givenInterruptedException
into aSourcedInterruptedException
if it is not yet of the same type and ifsource
is notnull
.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
Constructor Detail
-
SourcedInterruptedException
public SourcedInterruptedException(String message, InterruptedException cause, Throwable interruptSource)
- Parameters:
message
- mandatory message of this exceptioncause
- optional propagated causeinterruptSource
- optional propagated source ofThread.interrupt()
call
-
SourcedInterruptedException
public SourcedInterruptedException(InterruptedException cause, Throwable interruptSource)
- Parameters:
cause
- mandatory propagated causeinterruptSource
- optional propagated source ofThread.interrupt()
call
-
-
Method Detail
-
wrap
public static InterruptedException wrap(InterruptedException ie)
Wraps the givenInterruptedException
into aSourcedInterruptedException
if it is not yet of the desired type and if the current thread if aInterruptSource
, 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.- Parameters:
ie
- the to be wrappedInterruptedException
-
wrap
public static InterruptedException wrap(InterruptedException ie, InterruptSource source)
Wraps the givenInterruptedException
into aSourcedInterruptedException
if it is not yet of the same type and ifsource
is notnull
.Otherwise the given
InterruptedException
instance is returned.In case method is creating a new wrapping instance,
InterruptSource.clearInterruptSource()
is being issued.- Parameters:
ie
- the to be wrappedInterruptedException
source
- theInterruptSource
-
getInterruptSource
public final Throwable getInterruptSource()
Returns the source of theThread.interrupt()
call if known, otherwisenull
is returned.
-
getCause
public InterruptedException getCause()
Returns the propagatedInterruptedException
, i.e. the cause of this exception, ornull
if not applicable.
-
printCauseStack
public final void printCauseStack(PrintStream s, String causeStr, int causeIdx, int stackDepth)
Description copied from interface:ExceptionUtils.CustomStackTrace
- Specified by:
printCauseStack
in interfaceExceptionUtils.CustomStackTrace
- Parameters:
s
- output streamcauseStr
- the cause titlecauseIdx
- the cause index over all causes known by callerstackDepth
- the maximum depth for stack entries, or-1
for all
-
printStackTrace
public final void printStackTrace(PrintStream s, int causeDepth, int stackDepth)
Description copied from interface:ExceptionUtils.CustomStackTrace
CustomprintStackTrace
method, similar toThrowable#printStackTrace(PrintStream, int, int)
.- Specified by:
printStackTrace
in interfaceExceptionUtils.CustomStackTrace
- Parameters:
s
- output streamcauseDepth
- the maximum depth for causes, or-1
for allstackDepth
- the maximum depth for stack entries, or-1
for all
-
-