jess
Class JessException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjess.JessException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ParseException, RuleCompilerException, TerminatedException

public class JessException
extends java.lang.Exception
implements java.io.Serializable

This is the base class of all exceptions thrown by any functions in the Jess library. JessException is rather complex, as exception classes go. An instance of this class can contain a wealth of information about an error that occurred in Jess. Besides the typical error message, a JessException may be able to tell you the name of the routine in which the error occurred, the name of the Jess constructs that were on the exceution stack, the relevant text and line number of the executing Jess language program, and the Java exception that triggered the error (if any.)

One of the most important pieces of advice for working with the Jess library is that in your catch clauses for JessException, display the exception object. Print it to System.out, or convert to a String and display it in a dialog box, or log it, or something. The exceptions are there to help you by telling when something goes wrong; please don't ignore them.

Another important tip: the JessException class has a method getCause() which returns non-null when a particular JessException is a wrapper for another kind of exception. For example, if your Jess code calls a Java function that throws an exception, then the Jess code will throw a JessException, and calling getCause() will return the real exception that was thrown. Your JessException handlers should always check getCause; if your handler simply displays a thrown exception, then it should display the return value of getCause, too.

(C) 2006 Sandia National Laboratories

See Also:
Serialized Form

Field Summary
static int CLASS_NOT_FOUND
           
static int GENERAL_ERROR
           
static int NO_ERROR
           
 
Constructor Summary
JessException(java.lang.String routine, java.lang.String msg, int data)
          Constructs a JessException containing a descriptive message.
JessException(java.lang.String routine, java.lang.String msg, java.lang.String data)
          Constructs a JessException containing a descriptive message.
JessException(java.lang.String routine, java.lang.String msg, java.lang.Throwable t)
          Constructs a JessException containing a nested exception.
 
Method Summary
 java.lang.Throwable getCause()
          Get any nested exception object.
 java.lang.String getContext()
          Get the context information for this error.
 java.lang.String getData()
          Get the extra error data.
 java.lang.String getDetail()
          Get the error message.
 int getErrorCode()
          Returns one of the error codes in class ParseException.
 int getLineNumber()
          Get the program line number where the error occurred.
 java.lang.String getProgramText()
          Get the Jess program fragment that led to this exception
 java.lang.String getRoutine()
          Get the Java routine name where this error occurred
 void setErrorCode(int code)
          Set the error code for this exception.
 java.lang.String toString()
          Returns a String representation of this JessException.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_ERROR

public static final int NO_ERROR
See Also:
Constant Field Values

GENERAL_ERROR

public static final int GENERAL_ERROR
See Also:
Constant Field Values

CLASS_NOT_FOUND

public static final int CLASS_NOT_FOUND
See Also:
Constant Field Values
Constructor Detail

JessException

public JessException(java.lang.String routine,
                     java.lang.String msg,
                     java.lang.String data)
Constructs a JessException containing a descriptive message. The three separate arguments make it easy to assemble a message from pieces.

Parameters:
routine - the name of the routine this exception occurred in.
msg - an informational message.
data - usually some data; appended to msg after a space.

JessException

public JessException(java.lang.String routine,
                     java.lang.String msg,
                     int data)
Constructs a JessException containing a descriptive message. The three separate arguments make it easy to assemble a message from pieces.

Parameters:
routine - the name of the routine this exception occurred in.
msg - an informational message.
data - usually some data; appended to msg after a space.

JessException

public JessException(java.lang.String routine,
                     java.lang.String msg,
                     java.lang.Throwable t)
Constructs a JessException containing a nested exception.

Parameters:
routine - the name of the routine this exception occurred in.
msg - an informational message.
t - another type of exception that this object wraps
Method Detail

getCause

public java.lang.Throwable getCause()
Get any nested exception object. If Jess encounters a Java exception during execution, a JessException will be thrown and this method will return the original Java exception. getCause replaces the old getNextException() method, now removed.

Returns:
Value of nextException. Returns null if none.

getLineNumber

public int getLineNumber()
Get the program line number where the error occurred.

Returns:
Value of lineNumber.

getDetail

public java.lang.String getDetail()
Get the error message.

Returns:
Value of message.

getRoutine

public java.lang.String getRoutine()
Get the Java routine name where this error occurred

Returns:
Value of routine.

getData

public java.lang.String getData()
Get the extra error data.

Returns:
Value of data.

getProgramText

public java.lang.String getProgramText()
Get the Jess program fragment that led to this exception

Returns:
Value of programText.

getContext

public java.lang.String getContext()
Get the context information for this error.

Returns:
The context

toString

public java.lang.String toString()
Returns a String representation of this JessException. The String includes the routine name, message, and any contexts that have been added.

Returns:
a string containing this information.

getErrorCode

public int getErrorCode()
Returns one of the error codes in class ParseException.

Returns:
the error code

setErrorCode

public void setErrorCode(int code)
Set the error code for this exception. The argument should be one of the error codes in class ParseException.

Parameters:
code - the desired error code

© 2007 Sandia Corporation