Class KernelRuntimeException

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    InternalErrorException, InvalidStateException, NoRoomException, NoTokenException, UnknownResultException

    public class KernelRuntimeException
    extends java.lang.RuntimeException
    Base class for runtime exceptions. This class extends the basic Java RuntimeException with a constructor that can take a Nameable as an argument.

    This exception supports all the constructor forms of KernelException, but is implemented as a RuntimeException so that it does not have to be declared.

    The cause argument to the constructor is a Throwable that caused the exception. The cause argument is used when code throws an exception and we want to rethrow the exception but print the stacktrace where the first exception occurred. This is called exception chaining.

    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. See the KernelException documentation for differences between our exception chaining implementation and the JDK1.4 implementation.

    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    Edward A. Lee, Christopher Hylands
    See Also:
    Serialized Form
    Pt.AcceptedRating:
    Green (cxh)
    Pt.ProposedRating:
    Green (cxh)
    • Constructor Summary

      Constructors 
      Constructor Description
      KernelRuntimeException()
      Construct an exception with no specific detail message.
      KernelRuntimeException​(java.lang.String detail)
      Construct an exception with only a detail message.
      KernelRuntimeException​(java.lang.Throwable cause, java.lang.String detail)
      Construct an exception with a cause and a detail message.
      KernelRuntimeException​(java.util.Collection objects, java.lang.Throwable cause, java.lang.String detail)
      Construct an exception with a detail message that includes the names of a collection of Nameable objects plus the argument string.
      KernelRuntimeException​(Nameable object, java.lang.String detail)
      Construct an exception with a detail message that includes the name of the first argument and the value of the second argument string.
      KernelRuntimeException​(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 value of the fourth argument string.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      java.lang.Throwable getCause()
      Get the cause of this exception.
      java.lang.String getMessage()
      Get the message of this exception.
      java.util.Collection getNameables()
      Get the first 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.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getLocalizedMessage, getStackTrace, getSuppressed, initCause, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • KernelRuntimeException

        public KernelRuntimeException()
        Construct an exception with no specific detail message.
      • KernelRuntimeException

        public KernelRuntimeException​(java.lang.String detail)
        Construct an exception with only a detail message.
        Parameters:
        detail - The message.
      • KernelRuntimeException

        public KernelRuntimeException​(java.lang.Throwable cause,
                                      java.lang.String detail)
        Construct an exception with a cause and a detail message.
        Parameters:
        cause - The cause of this exception.
        detail - The message.
      • KernelRuntimeException

        public KernelRuntimeException​(Nameable object,
                                      java.lang.String detail)
        Construct an exception with a detail message that includes the name of the first argument and the value of the second argument string.
        Parameters:
        object - The object.
        detail - The message.
      • KernelRuntimeException

        public KernelRuntimeException​(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 value of the fourth argument string. If the cause argument is non-null, then the message of this exception will include the message of the cause argument. The stack trace of the cause argument is used when we print the stack trace of this exception. If one or more of the parameters are null, then the detail message is adjusted accordingly.
        Parameters:
        object1 - The first object.
        object2 - The second object.
        cause - The cause of this exception.
        detail - The message.
      • KernelRuntimeException

        public KernelRuntimeException​(java.util.Collection objects,
                                      java.lang.Throwable cause,
                                      java.lang.String detail)
        Construct an exception with a detail message that includes the names of a collection of Nameable objects plus the argument string.
        Parameters:
        objects - The Collection of Nameable objects
        cause - The cause of this exception.
        detail - The message.
    • Method Detail

      • getCause

        public java.lang.Throwable getCause()
        Get the cause of this exception.
        Overrides:
        getCause in class java.lang.Throwable
        Returns:
        The cause that was passed in as an argument to the constructor, or null if no cause was specified.
      • getMessage

        public java.lang.String getMessage()
        Get the message of this exception. The message may have been adjusted if one of the constructor arguments was null, so the value returned by this method may not necessarily equal the value of the detail argument of of the constructor.
        Overrides:
        getMessage in class java.lang.Throwable
        Returns:
        The error message.
      • getNameables

        public java.util.Collection getNameables()
        Get the first Nameable, if any, that was passed as an argument.
        Returns:
        The first Nameable that was passed in. If no Nameable was passed in, then return null.
      • printStackTrace

        public 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.
        Overrides:
        printStackTrace in class java.lang.Throwable
      • printStackTrace

        public 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.
        Overrides:
        printStackTrace in class java.lang.Throwable
        Parameters:
        printStream - The PrintStream to write to.
      • printStackTrace

        public 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.
        Overrides:
        printStackTrace in class java.lang.Throwable
        Parameters:
        printWriter - The PrintWriter to write to.
      • _setCause

        protected void _setCause​(java.lang.Throwable cause)
        Set the cause to the specified throwable.
        Parameters:
        cause - The cause of this exception
      • _setMessage

        protected void _setMessage​(java.lang.String message)
        Sets the error message to the specified string. If the message argument is null, then the error message is set to the empty string.
        Parameters:
        message - The message.