Re: catch replacing useful errorInfo



tom.rmadilo wrote:
error $err $::errorInfo $::errorCode

Yes you are right, if you do a catch, you should somehow log the
current value of errorInfo. You really need to also log where the
catch takes place, because the location of the catch is not part of
the errorInfo. Catch destroys this information, in this specific
sense.

Either you're just plain wrong, or I don't understand what you're saying. Let's look at the corrected example again:

% proc err {} {incr foo oops! ;# error here}
% proc errCaller {} err
% proc demo {} {
if {[catch errCaller msg] == 1} {
error $msg $::errorInfo $::errorCode
}
}
% demo
expected integer but got "oops!"
% set errorInfo
expected integer but got "oops!"
(reading increment)
invoked from within
"incr foo oops! "
(procedure "err" line 1)
invoked from within
"err"
(procedure "errCaller" line 1)
invoked from within
"errCaller"
(procedure "demo" line 2)
invoked from within
"demo"

Now, in the context of this example, can you please point to
what information was "destroyed". It appears to me that
all procs on the call stack at the time of the original error
appear in the $::errorInfo, providing complete data on the
context of the error.

Maybe more later if we get this misunderstanding cleared up.

DGP
.


Quantcast