$::errorCode contains error information in various cases (see the man page above); one of these cases is the exit status of the last exec or open "|..."/close pair that received an error.
See also tclvars, error, errorInfo, and return.
Anyone have good programming practices for using this? (The exec page gives a start at handling $::errorCode for [exec] or [open "|..."].)
DKF writes in Interrupting loops:
- The global errorCode variable is probably the best way to detect what kind of error happened; all too often it is shamefully ignored by the majority of scripts, and yet it is far easier for scripts to handle it than the errorInfo variable or the message string itself.
One way to encourage setting the errorCode would be to propose additional error classes. The standard ARITH, CHILD*, NONE, and POSIX only cover a fraction of all possible error conditions.
- Processing cancelled by user. Most code that might catch this should probably re-throw it, possibly after doing some cleanup.
[Say a few words on how errorCode is currently used, and not used, and how it might be better used. Relate to discussion [L1 ].]
"expect_out(buffer) has the content of the previous send"
[ Tcl syntax help | Category Debugging ]