catch replacing useful errorInfo



Group,
I was wondering if there was a way to not lose the error stack trace
when using the catch command. For example:

proc read_data {args} {
if {[catch {gen_data} msg]} { error $msg }
}

proc gen_data {args} {
gen_data:sub
}

proc gen_data:sub {args} {
incr i "oops"
}

If you run "gen_data", the errorInfo variable has the following
contents:
expected integer but got "oops"
while executing
"incr i "oops""
(procedure "gen_data:sub"; line 3)
invoked from within
"gen_data:sub";
(procedure "gen_data" line 2)
invoked from within
"gen_data"

If you run "read_data", the errorInfo variable has the following
contents:
expected integer but got "oops"
while executing
"error $msg"
(procedure "read_data" line 3)
invoked from within
"read_data"


The "gen_data" errorInfo has much more debug information that can
point me to my mistake. However, in order to fail gracefully, I like
to use a lot of catch statements and, thus, often lose a lot of useful
debug information.

Is there a different way to accomplish what I want to do but still
keep the more verbose errorInfo in tact?

Thanks,
JG

.



Relevant Pages

  • Re: NRE committed: PLEASE TEST
    ... be a proc, and hence you could pass in arguments and have them update ... so you give an argument to the coroutine and it pops out as the ... that a design decision, or a practical limitation? ... foreach arg [info args $proc] { ...
    (comp.lang.tcl)
  • Re: de-listing a list to use as proc arguments
    ... TCL proc. ... Or I can write it using "args" and call it in this way: ... applying it as arguments to a proc. ... define suma = curry sum ...
    (comp.lang.tcl)
  • Re: Help Passing Variables
    ... proc atst { ... set a [lindex $alst 0] ... Is the use of the term args tied to the "called" procedure, i.e. 'proc sum args {' then using $args within it to extract the variables. ...
    (comp.lang.tcl)
  • Re: tk_openFile errors on files within vfs
    ... proc::tk_getOpenFile {args} { ... The problem is that the native dialogs don't grok the Tcl VFS. ...
    (comp.lang.tcl)
  • Re: de-listing a list to use as proc arguments
    ... TCL proc. ... Or I can write it using "args" and call it in this way: ... applying it as arguments to a proc. ... Starting with 8.5 there is the expansion operator, ...
    (comp.lang.tcl)