On 1/3/23 09:36, Petro Kazmirchuk wrote:
This is how -errorinfo looks when I call [foo] directly:
my error
while executing
"throw AAA "my error""
(procedure "bar" line 2)
invoked from within
"bar"
(procedure "foo" line 2)
invoked from within
"foo"
("try" body line 3)
nice and clean - this is what I want to achieve with [duration]
Let's try to handle the error:
proc duration {script varName} {
upvar 1 $varName elapsed
set now [clock millis]
if {[catch {uplevel 1 $script} result errOpts]} {
dict incr errOpts -level ;# makes no difference, but I did my due diligence
return -options $errOpts $result
}
set elapsed [expr {[clock millis] - $now}]
}
resulting -errorinfo:
my error
while executing
"throw AAA "my error""
(procedure "bar" line 2)
invoked from within
"bar"
(procedure "foo" line 2)
invoked from within
"foo"
("uplevel" body line 2)
invoked from within
"uplevel 1 $script"
invoked from within
"duration {
foo
} elapsed"
("try" body line 2)
P.S. is it possible to format Tcl code somehow here? it becomes really unreadable after posting :(
You only did part of the work -- remove the uplevel from the trace in
errOpts (any anything else you want).
It is all under your control.
--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email:
[email protected] | +----------------------------------------------------------------------+
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)