<HTML><HEAD><TITLE>Built-In Commands - error manual page</TITLE></HEAD><BODY> <H3><A NAME="M2">NAME</A></H3> error - Generate an error <H3><A NAME="M3">SYNOPSIS</A></H3> <B>error </B><I>message</I> ?<I>info</I>? ?<I>code</I>?<BR> <H3><A NAME="M4">DESCRIPTION</A></H3> Returns a TCL_ERROR code, which causes command interpretation to be unwound. <I>Message</I> is a string that is returned to the application to indicate what went wrong. <P> If the <I>info</I> argument is provided and is non-empty, it is used to initialize the global variable <B>errorInfo</B>. <B>errorInfo</B> is used to accumulate a stack trace of what was in progress when an error occurred; as nested commands unwind, the Tcl interpreter adds information to <B>errorInfo</B>. If the <I>info</I> argument is present, it is used to initialize <B>errorInfo</B> and the first increment of unwind information will not be added by the Tcl interpreter. In other words, the command containing the <B>error</B> command will not appear in <B>errorInfo</B>; in its place will be <I>info</I>. This feature is most useful in conjunction with the <B><A HREF="../TkCmd/catch.htm">catch</A></B> command: if a caught error cannot be handled successfully, <I>info</I> can be used to return a stack trace reflecting the original point of occurrence of the error: <PRE><B>catch {...} errMsg set savedInfo $errorInfo ... error $errMsg $savedInfo</B></PRE> <P> If the <I>code</I> argument is present, then its value is stored in the <B>errorCode</B> global variable. This variable is intended to hold a machine-readable description of the error in cases where such information is available; see the <B><A HREF="../TkCmd/tclvars.htm">tclvars</A></B> manual page for information on the proper format for the variable. If the <I>code</I> argument is not present, then <B>errorCode</B> is automatically reset to ``NONE'' by the Tcl interpreter as part of processing the error generated by the command. <H3><A NAME="M5">SEE ALSO</A></H3> <B><A HREF="../TkCmd/catch.htm">catch</A></B>, <B><A HREF="../TkCmd/tclvars.htm">tclvars</A></B> <H3><A NAME="M6">KEYWORDS</A></H3> <A href="../Keywords/E.htm#error">error</A>, <A href="../Keywords/E.htm#errorCode">errorCode</A>, <A href="../Keywords/E.htm#errorInfo">errorInfo</A> <HR><PRE> <A HREF="../copyright.htm">Copyright</A> © 1993 The Regents of the University of California. <A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc. <A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> </BODY></HTML>