Version 6 of errorInfo

Updated 2002-10-24 19:44:34

http://www.purl.org/tcl/home/man/tcl8.4/TclCmd/tclvars.htm

[Someone want to comment on where this global variable gets set and to what good uses one can put it to?]

RS: Contains the error message and traceback of the last error. Silly example:

 % proc foo {} {bar x}
 % proc bar {input} {grill$input}
 % foo
 invalid command name "grillx"
 % set errorInfo
 invalid command name "grillx"
    while executing
 "_unknown grillx"
    ("eval" body line 1)
    invoked from within
 "eval _unknown $args"
    (procedure "unknown" line 17)
    invoked from within
 "grill$input"
    (procedure "bar" line 1)
    invoked from within
 "bar x"
    (procedure "foo" line 1)
    invoked from within
 "foo"

This tells us that unknown raised the error when trying to resolve grillx, called in bar, called in foo. (It does not tell us that the real bug was a missing space between grill and $input.. that's up to the coder to find out. But the traceback may help to narrow in on the bug, at least).

See also errorCode.


DGP Whoa! What interpreter was that example created in? I think Wiki examples are best done in a plain tclsh, or with a statement about what special interp you are using instead. Here's what I see:

 % set errorInfo
 invalid command name "grillx"
     while executing
 "grill$input"
     (procedure "bar" line 1)
     invoked from within
 "bar x"
     (procedure "foo" line 1)
     invoked from within
 "foo"

RS admits that it was his sandbox, with Radical language modification in the back room...

DGP Better check your RLM, then. You probably want to have [uplevel 1 _unknown $args] instead of [eval _unknown $args].

RS admits the bug - see how helpful an intercontinental errorInfo can be! Thanks, Don!


Tcl syntax help