|
|
This code sample is used in the following examples:
proc doit1 cbs { # an intentionally malformed command for not_enough_args }proc doit2 cbs { # an intentionally unrecognized command egko doit2 }
proc freddy {} { # an intentionally incorrect number of arguments if leg }
# Main
set f1 [VtOpen error] set f [VtForm $f1.f ] VtPushButton $f.b -label "err1" -callback doit1 VtPushButton $f.b1 -label "err2" -callback doit2 VtPushButton $f.b2 -label "noCallBack" -callback nocallback
# generate this error if give arg to script if {[llength $argv] != 0 } freddy
VtShow $f
VtMainLoop
The user enters:
# vtcl err.tcl err
This command produces the following stack trace:
Error: syntax error in expression "leg" syntax error in expression "leg" while executing "if leg" (procedure "freddy" line 2) invoked from within "freddy" invoked from within "if {[llength $argv] != 0 } freddy" (file "err.tcl" line 23)The command generated an error in the procedure freddy while trying to treat the first argument of the if command (``leg'') as an expression. The stack trace displays the line where the error was detected and from where the command was invoked.
The user enters:
# vtcl err.tcl
The user then presses the button labeled err1.
This action produces the following stack trace:
Error: wrong # args: should be "for start test next command" wrong # args: should be "for start test next command" while executing "for not_enough_args" (procedure "doit1" line 3) invoked from within "doit1 {{dialog {}} {widget .error.f.b} {clickCount 1} {value err1} {mode select}}" invoked from within "VtMainLoop" (file "err.tcl" line 25)This stack shows the error due to the incorrect argument count in the line containing
for not_enough_args
and the name
of the procedure in which the error occurred (doit1).
The stack trace indicates that the procedure was called from
within VtMainLoop and that the procedure
is a callback.
The user enters:
# vtcl err.tcl
The user then presses the button labeled err2.
This action produces the following stack trace:
Error: invalid command name "egko" invalid command name "egko" while executing "error "invalid command name invoked from within "if {!$tcl_interactive || ([info level] > 2) || [info script] != ""} { error "invalid command name }" (procedure "tclx_unknown2" line 17) invoked from within "tclx_unknown2 $args" invoked from within "return [tclx_unknown2 $args]..." (procedure "unknown" line 8) invoked from within "egko doit2" (procedure "doit2" line 3) invoked from within "doit2 {{dialog {}} {widget .error.f.b1} {clickCount 1} {value err2} { mode select}}" invoked from within "VtMainLoop" (file "err.tcl" line 25)This is a typical dump for an unrecognized, or mistyped, command. It is complicated by the dump of the trace through unknown and tclx_unknown, which are used to implement autoloading of commands.
The important lines are:
invalid command name "egko" <unknown and tclx_unknown handling skipped> invoked from within "egko doit2" (procedure "doit2" line 3) invoked from within "doit2 {{dialog {}} {widget .error.f.b1} {clickCount 1} {value err2} {mode select}}" invoked from within "VtMainLoop" (file "err.tcl" line 25)
The user enters:
# vtcl err.tcl
The user then presses the button labeled noCallBack.
This action produces the following stack trace:
Error: invalid command name "nocallback" invalid command name "nocallback" while executing "error "invalid command name invoked from within "if {!$tcl_interactive || ([info level] > 2) || [info script] != ""} { error "invalid command name }" (procedure "tclx_unknown2" line 17) invoked from within "tclx_unknown2 $args" invoked from within "return [tclx_unknown2 $args]..." (procedure "unknown" line 8) invoked from within "nocallback {{dialog {}} {widget .error.f.b2} {clickCount 1} {value noCallBack} {mode select}}" invoked from within "VtMainLoop" (file "err.tcl" line 25)This stack is similar to the previous one, except that the error is coming from within MainLoop when it tries to find the missing procedure, rather than from inside the procedure itself.