Class UncheckedException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.postgresql.pljava.internal.UncheckedException
-
- All Implemented Interfaces:
Serializable
public final class UncheckedException extends RuntimeException
An unchecked exception to efficiently wrap checked Throwables.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 (asgetCause
is proxied to return the wrapped throwable's cause).- See Also:
- Serialized Form
-
-
Method Summary
Modifier and Type Method Description Throwable
fillInStackTrace()
Throwable
getCause()
String
getLocalizedMessage()
String
getMessage()
StackTraceElement[]
getStackTrace()
Throwable
initCause(Throwable cause)
void
printStackTrace()
void
printStackTrace(PrintStream s)
void
printStackTrace(PrintWriter s)
void
setStackTrace(StackTraceElement[] stackTrace)
String
toString()
static RuntimeException
unchecked(Exception e)
Return the exception e as aRuntimeException
.static RuntimeException
unchecked(Throwable t)
Return the throwable t as aRuntimeException
.Throwable
unwrap()
Return theThrowable
that thisUncheckedException
wraps.-
Methods inherited from class java.lang.Throwable
addSuppressed, getSuppressed
-
-
-
-
Method Detail
-
unchecked
public static RuntimeException unchecked(Exception e)
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
public static RuntimeException unchecked(Throwable t)
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
public Throwable 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
public Throwable fillInStackTrace()
- Overrides:
fillInStackTrace
in classThrowable
-
getLocalizedMessage
public String getLocalizedMessage()
- Overrides:
getLocalizedMessage
in classThrowable
-
getMessage
public String getMessage()
- Overrides:
getMessage
in classThrowable
-
getStackTrace
public StackTraceElement[] getStackTrace()
- Overrides:
getStackTrace
in classThrowable
-
printStackTrace
public void printStackTrace()
- Overrides:
printStackTrace
in classThrowable
-
printStackTrace
public void printStackTrace(PrintStream s)
- Overrides:
printStackTrace
in classThrowable
-
printStackTrace
public void printStackTrace(PrintWriter s)
- Overrides:
printStackTrace
in classThrowable
-
setStackTrace
public void setStackTrace(StackTraceElement[] stackTrace)
- Overrides:
setStackTrace
in classThrowable
-
-