3.3.4 Error Reporting and Exit

This method provides a uniform way to report errors in the compiled code.

*
[const char* $s$]tcl.error../Tcl/Tcl.ccTcl::error performs the following functions: write $s$ to stdout; write tcl_-result to stdout; exit with error code 1.
        {\bfseries{}tcl.resultf}("cmd = %s", cmd);
        {\bfseries{}tcl.error}("invalid command specified");
        /*{}NOTREACHED*/

Note that there are minor differences between returning TCL_ERROR as we did in the previous subsectionSectionsec:Result, and calling []Tcl::error. The former generates an exception within the interpreter; the user can trap the exception and possibly recover from the error. If the user has not specified any traps, the interpreter will print a stack trace and exit. However, if the code invokes []error, then the simulation user cannot trap the error; in addition, ns will not print any stack trace.



Tom Henderson 2014-12-17