public class KernelException
extends java.lang.Exception
JDK1.4 and later support exception chaining. We are implementing a version of exception chaining here ourselves so that we can use JVMs earlier than JDK1.4.
In this implementation, we have the following differences from the JDK1.4 exception chaining implementation:
KernelRuntimeException
,
Serialized FormConstructor and Description |
---|
KernelException()
Construct an exception with a no specific detail message.
|
KernelException(Nameable object1,
Nameable object2,
java.lang.String detail)
Construct an exception with a detail message that includes the
names of the first two arguments plus the third argument
string.
|
KernelException(Nameable object1,
Nameable object2,
java.lang.Throwable cause,
java.lang.String detail)
Construct an exception with a detail message that includes the
names of the first two arguments plus the third argument
string.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_setCause(java.lang.Throwable cause)
Set the cause to the specified throwable.
|
protected void |
_setMessage(java.lang.String message)
Sets the error message to the specified string.
|
static java.lang.String |
generateMessage(java.util.Collection objects,
java.lang.Throwable cause,
java.lang.String detail)
Generate a properly formatted exception message where the
origin of the error is a collection.
|
static java.lang.String |
generateMessage(Nameable object1,
Nameable object2,
java.lang.Throwable cause,
java.lang.String detail)
Generate a properly formatted exception message.
|
static java.lang.String |
generateMessage(java.lang.String whereString,
java.lang.Throwable cause,
java.lang.String detail)
Generate a properly formatted detail message.
|
java.lang.Throwable |
getCause()
Get the cause of this exception.
|
static java.lang.String |
getFullName(Nameable object)
Get the name of a Nameable object.
|
java.lang.String |
getMessage()
Get the message of this exception.
|
static java.lang.String |
getName(Nameable object)
Get the name of a Nameable object.
|
Nameable |
getNameable1()
Get the first Nameable, if any, that was passed as an argument.
|
Nameable |
getNameable2()
Get the second Nameable, if any, that was passed as an argument.
|
void |
printStackTrace()
Print a stack trace message to stderr including
this exception, its stack trace and if the cause
exception is known, print the cause exception and the
cause stacktrace.
|
void |
printStackTrace(java.io.PrintStream printStream)
Print a stack trace message to printStream including this
exception, its stack trace and if the cause exception is
known, print the cause exception and the cause stacktrace.
|
void |
printStackTrace(java.io.PrintWriter printWriter)
Print a stack trace message to printWriter including this
exception, its stack trace and if the cause exception is
known, print the cause exception and the cause stacktrace.
|
static java.lang.String |
stackTraceToString(java.lang.Throwable throwable)
Return the stack trace of the given argument as a String.
|
public KernelException()
public KernelException(Nameable object1, Nameable object2, java.lang.String detail)
object1
- The first object.object2
- The second object.detail
- The message.public KernelException(Nameable object1, Nameable object2, java.lang.Throwable cause, java.lang.String detail)
object1
- The first object.object2
- The second object.cause
- The cause of this exception.detail
- The message.public static java.lang.String generateMessage(Nameable object1, Nameable object2, java.lang.Throwable cause, java.lang.String detail)
This method is public static so that both KernelException and KernelRuntimeException and any classes derived from those classes can use it. KernelRuntimeException must extend RuntimeException so that the java compiler will allow methods that throw KernelRuntimeException to not declare that they throw it, and KernelException cannot extend RuntimeException for the same reason.
object1
- The first object.object2
- The second object.cause
- The cause of this exception.detail
- The detail message.public static java.lang.String generateMessage(java.util.Collection objects, java.lang.Throwable cause, java.lang.String detail)
This method is public static so that both KernelException and KernelRuntimeException and any classes derived from those classes can use it. KernelRuntimeException must extend RuntimeException so that the java compiler will allow methods that throw KernelRuntimeException to not declare that they throw it, and KernelException cannot extend RuntimeException for the same reason.
objects
- The where objects.cause
- The cause of this exception.detail
- The detail message.public static java.lang.String generateMessage(java.lang.String whereString, java.lang.Throwable cause, java.lang.String detail)
This method is public static so that both KernelException and KernelRuntimeException and any classes derived from those classes can use it. KernelRuntimeException must extend RuntimeException so that the java compiler will allow methods that throw KernelRuntimeException to not declare that they throw it, and KernelException cannot extend RuntimeException for the same reason.
whereString
- The string that identifies where the error occurred,
as in for example "in object: foo".cause
- The cause of this exception.detail
- The message.public java.lang.Throwable getCause()
getCause
in class java.lang.Throwable
public static java.lang.String getFullName(Nameable object)
This method is public static so that both KernelException and KernelRuntimeException and any classes derived from those classes can use it. KernelRuntimeException must extend RuntimeException so that the java compiler will allow methods that throw KernelRuntimeException to not declare that they throw it, and KernelException cannot extend RuntimeException for the same reason.
object
- An object with a full name.public java.lang.String getMessage()
getMessage
in class java.lang.Throwable
public static java.lang.String getName(Nameable object)
object
- An object with a name.public Nameable getNameable1()
public Nameable getNameable2()
public void printStackTrace()
printStackTrace
in class java.lang.Throwable
public void printStackTrace(java.io.PrintStream printStream)
printStackTrace
in class java.lang.Throwable
printStream
- The PrintStream to write to.public void printStackTrace(java.io.PrintWriter printWriter)
printStackTrace
in class java.lang.Throwable
printWriter
- The PrintWriter to write to.public static java.lang.String stackTraceToString(java.lang.Throwable throwable)
throwable
- A throwable.protected void _setCause(java.lang.Throwable cause)
cause
- The cause of this exceptionprotected void _setMessage(java.lang.String message)
message
- The message.