|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.apache.commons.lang.exception.NestableRuntimeException
org.apache.commons.lang.UnhandledException
net.sf.staccatocommons.lang.SoftException
public class SoftException
A SoftException is a RuntimeException that wraps another with
only solely purpose of making it unchecked.
| Field Summary |
|---|
| Fields inherited from class org.apache.commons.lang.exception.NestableRuntimeException |
|---|
delegate |
| Method Summary | ||
|---|---|---|
static
|
callOrSoften(Callable<T> callable)
Tries return callable.call(). |
|
static Exception |
harden(RuntimeException runtimeException)
Converts a given RuntimeException into a checked Exception,
if possible. |
|
static Exception |
harden(SoftException e)
Converts the given SoftException into a checked Exception,
by returning its cause |
|
static RuntimeException |
soften(Throwable exception)
Converts an exception into a RuntimeException, either by casting
it, if possible, or wrapping it into a SoftException |
|
static
|
valueOrHarden(net.sf.staccatocommons.defs.Thunk<T> thunk)
Tries to return thunk.value(). |
|
| Methods inherited from class org.apache.commons.lang.exception.NestableRuntimeException |
|---|
getCause, getMessage, getMessage, getMessages, getThrowable, getThrowableCount, getThrowables, indexOfThrowable, indexOfThrowable, printPartialStackTrace, printStackTrace, printStackTrace, printStackTrace |
| Methods inherited from class java.lang.Throwable |
|---|
fillInStackTrace, getLocalizedMessage, getStackTrace, initCause, setStackTrace, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
@NonNull
public static RuntimeException soften(@NonNull
Throwable exception)
RuntimeException, either by casting
it, if possible, or wrapping it into a SoftException
exception - the target exception to soften.
exception, casted to
RuntimeException, if possible, or a new
SoftException that wrapps it, otherwise.
@NonNull
public static Exception harden(@NonNull
SoftException e)
SoftException into a checked Exception,
by returning its cause
e - the soft exception to harden
@NonNull
public static Exception harden(@NonNull
RuntimeException runtimeException)
RuntimeException into a checked Exception,
if possible.
This method traverses the throwable causes chain, until a non
RuntimeException is found. If such throwable exists and is an
Exception, it returns it. Otherwise, returns the original
runtimeException
runtimeException -
RuntimeException in the causes chain, if
exists and is an Exception. The given
RuntimeException otherwise.
public static <T> T callOrSoften(@NonNull
Callable<T> callable)
callable.call(). If an exception is thrown, it is
softened and rethrown.
T - the callable return typecallable - the callable to execute. Non null.
Callable.call() succeeds
RuntimeException - if the call failed#soften(Exception)
public static <T> T valueOrHarden(@NonNull
net.sf.staccatocommons.defs.Thunk<T> thunk)
throws Exception
thunk.value(). If an exception is thrown, it
is hardened and rethrown
T - the thunk return typethunk -
Thunk, if it succeeds
Exception - if Thunk.value() failedThunk,
harden(RuntimeException)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||