jess
Class JessException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by jess.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) 2013 Sandia Corporation

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.String data, java.lang.String filename)
          Constructs a JessException containing a descriptive message.
JessException(java.lang.String routine, java.lang.String msg, java.lang.String data, java.lang.String filename, java.lang.Throwable t)
          Constructs a JessException containing a nested exception.
JessException(java.lang.String routine, java.lang.String msg, java.lang.String data, java.lang.Throwable t)
          Constructs a JessException containing a nested exception.
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.
 Context getExecutionContext()
          Get the Context active at the time of the error, if available.
 java.lang.String getFilename()
          Get the name of the Jess language source file where the error occurred.
 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.
 void setFilename(java.lang.String filename)
          Set the name of the Jess language source file where the error occurred.
 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,
                     java.lang.String data,
                     java.lang.String filename)
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.
filename - the name of the Jess language source file in which the error occurred

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

JessException

public JessException(java.lang.String routine,
                     java.lang.String msg,
                     java.lang.String data,
                     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

JessException

public JessException(java.lang.String routine,
                     java.lang.String msg,
                     java.lang.String data,
                     java.lang.String filename,
                     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
filename - the name of the Jess language source file in which the error occurred
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.

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

getFilename

public java.lang.String getFilename()
Get the name of the Jess language source file where the error occurred. Returns null if unknown.

Returns:
value of filename, or null

setFilename

public void setFilename(java.lang.String filename)
Set the name of the Jess language source file where the error occurred.

Parameters:
filename - value to assign to filename

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. This is the Jess language equivalent of a Java stack trace. It will include a line for each function, rule, Rete node, etc which is on Jess's call stack at the time of the error.

Returns:
The context, or null if no information

getExecutionContext

public Context getExecutionContext()
Get the Context active at the time of the error, if available.

Returns:
The active Context or null

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.

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

2013 Sandia Corporation