Class UncheckedException
- All Implemented Interfaces:
Serializable
This exception does not carry a message or stack trace of its own; most of
its methods proxy through to those of its 'cause', so that it does not appear
as an extra layer of indirection in a typical stack trace. It has one
specific new method, unwrap
, to obtain the actual wrapped
throwable (as getCause
is proxied to return the wrapped throwable's
cause).
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetCause()
void
void
void
void
setStackTrace
(StackTraceElement[] stackTrace) toString()
static RuntimeException
Return the exception e as aRuntimeException
.static RuntimeException
Return the throwable t as aRuntimeException
.unwrap()
Return theThrowable
that thisUncheckedException
wraps.Methods inherited from class java.lang.Throwable
addSuppressed, getSuppressed
-
Method Details
-
unchecked
Return the exception e as aRuntimeException
.Intended for use in a
throw unchecked(e);
construct. If e is already an unchecked exception, it is simply returned; otherwise, it is returned wrapped.- Returns:
- the supplied exception, possibly wrapped
-
unchecked
Return the throwable t as aRuntimeException
.Intended for use in a
throw unchecked(t);
construct. If t is already aRuntimeException
, it is simply returned; if it is anError
, it is thrown from this method; otherwise, it is returned wrapped.- Returns:
- the supplied exception, possibly wrapped
- Throws:
Error
- or a subclass, if that's what t is
-
unwrap
Return theThrowable
that thisUncheckedException
wraps.The familiar inherited methods proxy through to the wrapped throwable (so
getCause
will return its cause, and so on); this distinct method is provided to undo the wrapping.- Returns:
- the wrapped Throwable
-
fillInStackTrace
- Overrides:
fillInStackTrace
in classThrowable
-
getCause
-
getLocalizedMessage
- Overrides:
getLocalizedMessage
in classThrowable
-
getMessage
- Overrides:
getMessage
in classThrowable
-
getStackTrace
- Overrides:
getStackTrace
in classThrowable
-
initCause
-
printStackTrace
public void printStackTrace()- Overrides:
printStackTrace
in classThrowable
-
printStackTrace
- Overrides:
printStackTrace
in classThrowable
-
printStackTrace
- Overrides:
printStackTrace
in classThrowable
-
setStackTrace
- Overrides:
setStackTrace
in classThrowable
-
toString
-