tcl.lang
Class TclException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by tcl.lang.TclException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
TclNumArgsException, TclPosixException, TclVarException

public class TclException
extends Exception

TclException is used to interrupt the Tcl script currently being interpreted by the Tcl Interpreter. Usually, a TclException is thrown to indicate a script level error, e.g.: - A syntax error occurred in a script. - A unknown variable is referenced. - A unknown command is executed. - A command is passed incorrected. A TclException can also be thrown by Tcl control structure commands such as "return" and "continue" to change the flow of control in a Tcl script. A TclException is accompanied by two pieces of information: the error message and the completion code. The error message is a string stored in the interpreter result. After a TclException is thrown and caught, the error message can be queried by Interp.getResult(). The completion code indicates why the TclException is generated. It is stored in the compCode field of this class.

See Also:
Serialized Form

Field Summary
 int errIndex
          An index that indicates where an error occurs inside a Tcl string.
 
Constructor Summary
  TclException(int ccode)
          Create a TclException with the given completion code.
  TclException(Interp interp, String msg)
          Create an TclException with the given error message.
  TclException(Interp interp, String msg, int ccode)
          Create an TclException with the given error message and completion code.
protected TclException(Interp interp, String msg, int ccode, int idx)
          Create an TclException with the given error message and completion code and indicate the location of the error in a script.
 
Method Summary
 int getCompletionCode()
          getCompletionCode --
 void setCompletionCode(int ccode)
          Sets the current completion code.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

errIndex

public int errIndex
An index that indicates where an error occurs inside a Tcl string. This is used to add the offending command into the stack trace. A negative value means the location of the index is unknown. Currently this field is used only by the Jacl interpreter.

Constructor Detail

TclException

protected TclException(Interp interp,
                       String msg,
                       int ccode,
                       int idx)
Create an TclException with the given error message and completion code and indicate the location of the error in a script. Results: None. Side effects: The instance fields are initialized; the message is assigned to the interpreter's result if interp is non-null.

Parameters:
interp - current interpreter; may be null
msg - error message
ccode - completion code (TCL.ERROR, TCL.BREAK, etc)
idx - error index

TclException

public TclException(int ccode)
Create a TclException with the given completion code. Results: None. Side effects: The instance fields are initialized.

Parameters:
ccode - completion code

TclException

public TclException(Interp interp,
                    String msg)
Create an TclException with the given error message. The completion code is set to ERROR by default. Results: None. Side effects: The instance fields are initialized; the message is assigned to the interpreter's result if interp is non-null.

Parameters:
interp - current interpreter, may be null if unknown
msg - error message

TclException

public TclException(Interp interp,
                    String msg,
                    int ccode)
Create an TclException with the given error message and completion code. Results: None. Side effects: The instance fields are initialized; the message is assigned to the interpreter's result if interp is non-null.

Parameters:
interp - current interpreter, may be null if unknown
msg - error message
ccode - completion code
Method Detail

getCompletionCode

public final int getCompletionCode()
getCompletionCode --

Returns:
the current completion code (TCL.BREAK, TCL.OK, TCL.RETURN...).

setCompletionCode

public final void setCompletionCode(int ccode)
Sets the current completion code.

Parameters:
ccode - new completion code


Copyright © 2015. All rights reserved.