Sujet : Re: Show argument values in bgerror
De : wortkarg3 (at) *nospam* yahoo.com (Harald Oehlmann)
Groupes : comp.lang.tclDate : 18. Sep 2024, 15:54:35
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vcepjb$3vk7h$5@dont-email.me>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
Am 18.09.2024 um 15:21 schrieb alexandru:
Here is the errorInfo of a true life situation.
The value of "val" is not output.
Maybe it should and it was intended so, but it's not.
So it's a bug then...
Alexandru,
it is not a bug. I don't speak about $::errorInfo, but "info errorstack", or the "-errorstack" component of the error dict.
Here is a complete example as proposed by Don (thanks !):
proc bgerrorhandler {message errordict} {
puts "*** START OF ERROR MESSAGE ***"
puts $message
puts "*** ERROR INFO ***"
puts [dict get $errordict -errorinfo]
puts "*** ERROR STACK ***"
foreach {call arg} [dict get $errordict -errorstack] {
puts "$call:$arg"
}
puts "*** END OF ERROR MESSAGE ***"
}
interp bgerror "" bgerrorhandler
proc e1 {v} {incr v}
proc e2 {v} {e1 $v}
after idle {e2 a}
This gives the output:
*** START OF ERROR MESSAGE ***
expected integer but got "a"
*** ERROR INFO ***
expected integer but got "a"
while executing
"incr v"
(procedure "e1" line 1)
invoked from within
"e1 $v"
(procedure "e2" line 1)
invoked from within
"e2 a"
("after" script)
*** ERROR STACK ***
INNER:incrScalar1Imm
CALL:e1 a
CALL:e2 a
*** END OF ERROR MESSAGE ***
So, the error info has the variable names ($v in this case), while the error stack has the values ("a" in this case).
Might this suit your needs ?
Take care,
Harald