Re: catch replacing useful errorInfo
- From: Donald G Porter <dgp@xxxxxxxx>
- Date: Wed, 29 Aug 2007 13:57:39 -0400
Bryan Oakley wrote:
Donald G Porter wrote:
If you need to support Tcl 8.4 (or earlier):
package require Tcl 8.0
proc read_data {args} {
if {[catch {gen_data} msg]} {
error $msg $::errorInfo $::errorCode
}
}
Interesting. You advocate "error .." over "return -code error ...". Is there a technical reason or just a personal preference?
In this case my key reason was greater similarity to what the
OP was already doing.
Usually for me, the choice between [return -code error] vs [error]
should rest on whether the intent is to report back to the caller
that the arguments it passed you are unacceptable, or whether it's
really something internal to your own code that's going wrong. In
this instance, that choice also leads to [error].
Note that there's an assumption underlying this, that the OP really
has something more sophisticated in mind than the example he posted,
because for that example the best answer is to just not [catch]
in the first place.
DGP
.
- References:
- catch replacing useful errorInfo
- From: TronyQ
- Re: catch replacing useful errorInfo
- From: Donald G Porter
- Re: catch replacing useful errorInfo
- From: Bryan Oakley
- catch replacing useful errorInfo
- Prev by Date: Re: catch replacing useful errorInfo
- Next by Date: Re: Why do I need to "eval" this?
- Previous by thread: Re: catch replacing useful errorInfo
- Next by thread: Re: catch replacing useful errorInfo
- Index(es):
Relevant Pages
|