29package com.jogamp.common.util;
31import java.io.PrintStream;
33import com.jogamp.common.ExceptionUtils;
34import com.jogamp.common.ExceptionUtils.CustomStackTrace;
44@SuppressWarnings(
"serial")
46 final Throwable interruptSource;
62 public static InterruptedException
wrap(
final InterruptedException ie) {
80 public static InterruptedException
wrap(
final InterruptedException ie,
final InterruptSource source) {
98 this.interruptSource = interruptSource;
106 super(cause.getMessage());
108 this.interruptSource = interruptSource;
116 return interruptSource;
128 return (InterruptedException)super.getCause();
133 final StringBuilder sb =
new StringBuilder(256);
134 sb.append(getClass().getSimpleName()).append(
": ");
135 if (
null != interruptSource) {
136 sb.append(
"[sourced]");
138 sb.append(
"[unknown]");
140 final String m = getLocalizedMessage();
142 sb.append(
" ").append(m);
144 return sb.toString();
148 public final void printCauseStack(
final PrintStream s,
final String causeStr,
final int causeIdx,
final int stackDepth) {
149 final String s0 = causeStr+
"["+causeIdx+
"]";
150 s.println(s0+
" by "+getClass().getSimpleName()+
": "+getMessage()+
" on thread "+Thread.currentThread().getName());
152 if(
null != interruptSource ) {
158 public final void printStackTrace(
final PrintStream s,
final int causeDepth,
final int stackDepth) {
159 s.println(getClass().getSimpleName()+
": "+getMessage()+
" on thread "+Thread.currentThread().getName());
162 if(
null != interruptSource ) {
static int printCause(final PrintStream s, final String causeStr, Throwable cause, final int causeIdx, final int causeDepth, final int stackDepth)
Prints the given Throwable cause to the output PrintStream s.
static void dumpStack(final PrintStream out)
static InterruptSource currentThread()
Casts current java.lang.Thread to InterruptSource if applicable, otherwise returns null.
InterruptedException, which may include the source, see getInterruptSource().
final void printStackTrace(final PrintStream s, final int causeDepth, final int stackDepth)
Custom printStackTrace method, similar to Throwable#printStackTrace(PrintStream, int,...
final Throwable getInterruptSource()
Returns the source of the Thread#interrupt() call if known, otherwise null is returned.
SourcedInterruptedException(final InterruptedException cause, final Throwable interruptSource)
final void printCauseStack(final PrintStream s, final String causeStr, final int causeIdx, final int stackDepth)
Prints this Throwable as a cause to the output PrintStream s, not iterating over all inner causes!
InterruptedException getCause()
Returns the propagated InterruptedException, i.e.
static InterruptedException wrap(final InterruptedException ie, final InterruptSource source)
Wraps the given InterruptedException into a SourcedInterruptedException if it is not yet of the same ...
SourcedInterruptedException(final String message, final InterruptedException cause, final Throwable interruptSource)
static InterruptedException wrap(final InterruptedException ie)
Wraps the given InterruptedException into a SourcedInterruptedException if it is not yet of the desir...
Interface allowing Throwable specializations to provide their custom stack trace presentation.
Interface exposing java.lang.Thread#interrupt() source, intended for java.lang.Thread specializations...
Throwable getInterruptSource(final boolean clear)
Returns the source of the last interrupt() call.