Re: bug in 8.4.14 return -code error?
- From: Don Porter <dgp@xxxxxxxx>
- Date: Wed, 31 Jan 2007 12:49:03 -0500
Bryan Oakley wrote:
if {[catch {...
error \....
"error reported via error" \
"custom errorInfo" \
[list CUSTOM errorCode]
return \
-code error \
-errorinfo "custom errorInfo" \
-errorcode [list CUSTOM errorCode] \
"error reported via return"
Note the important difference between [catch error] and [catch return]. The first catches code value TCL_ERROR, the second catches code value TCL_RETURN.
In Tcl 8.4 and earlier the special -errorinfo and -errorcode values
to [return -code error] don't get transferred over to ::errorInfo
and ::errorCode until a proc returns TCL_ERROR. Since you are [catch]ing the [return] before a proc return ever converts TCL_RETURN to TCL_ERROR, that does not happen.
In Tcl 8.5, the -errorinfo and -errorcode switches to return are just particular cases of a general mechanism of setting return option values. Any value may be set, any value may be paired with any return code, and the values are stored immediately. The transfer over to ::errorInfo and ::errorCode is done to support legacy compatibility.
If the demonstrated incomaptibility in your example is important enough, it might be possible to limit that legacy compat transfer over to ::errorCode and ::errorInfo to more carefully determined circumstances.
--
| Don Porter Mathematical and Computational Sciences Division |
| donald.porter@xxxxxxxx Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
.
- Follow-Ups:
- Re: bug in 8.4.14 return -code error?
- From: Don Porter
- Re: bug in 8.4.14 return -code error?
- References:
- bug in 8.4.14 return -code error?
- From: Bryan Oakley
- bug in 8.4.14 return -code error?
- Prev by Date: Re: bug in 8.4.14 return -code error?
- Next by Date: Re: bug in 8.4.14 return -code error?
- Previous by thread: Re: bug in 8.4.14 return -code error?
- Next by thread: Re: bug in 8.4.14 return -code error?
- Index(es):