$errorCode, a variable managed by Tcl, contains the value of the -errorcode entry in the options dictionary that describes the last error encountered.
return creates an options dictionary which made available via catch and try. For convenience, when the evaluation of a command produces an error code, it is also written to $::errorCode.
DKF writes in Interrupting loops:
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.