com.sun.sgs.impl.sharedutil
Class Exceptions

java.lang.Object
  extended by com.sun.sgs.impl.sharedutil.Exceptions

public final class Exceptions
extends Object

Utility methods for working with Exceptions.


Method Summary
static String getStackTrace()
          Returns the caller's stack trace, in the typical format.
static
<T extends Throwable>
T
initCause(T exception, Throwable cause)
          Returns the given exception with its cause initialized.
static void throwUnchecked(Throwable exception)
          Throws an unchecked exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initCause

public static <T extends Throwable> T initCause(T exception,
                                                Throwable cause)
Returns the given exception with its cause initialized. The original exception is returned in a typesafe way so that it can be thrown easily.

Type Parameters:
T - the type of the parent exception
Parameters:
exception - the exception to initialize
cause - the cause
Returns:
the exception with its cause initialized
Throws:
IllegalArgumentException - if an attempt is made to set an exception as its own cause
IllegalStateException - if the exception has already had its cause initialized
See Also:
Throwable.initCause(Throwable)

getStackTrace

public static String getStackTrace()
Returns the caller's stack trace, in the typical format.

Returns:
the caller's stack trace, in the typical format

throwUnchecked

public static void throwUnchecked(Throwable exception)
Throws an unchecked exception. The argument must be a RuntimeException or an Error. This method always throws an exception.

Parameters:
exception - the exception to throw


Copyright © 2007-2013. All Rights Reserved.