Can you show how you capture / put information in non-interactive mode?
If you did
if {[catch {...your...code...here...} err]} { puts "Error info $err" }
Then the behavior that you described is expected - $err has only "brief information". Instead of puts you might want to:
puts "Error info $err\nFull info: $::errorInfo"
The :: prefix is required if your catch is called inside a proc or namespace to make sure that the variable you are using is the actual toplevel :: errorInfo.
Edited for addressing
As Colin answered , the stack traces found in your test1 and test2 are different in that you put catch. Let me illustrate. Here are a few Tcl chains:
proc one {} { two } proc two {} { three } proc three {} { four } proc four {} { error "Yup, an error" }
If you rate
catch {four} puts $::errorInfo
You will only get a stack trace that looks like this:
Yup, an error while executing "error "Yup, an error"" (procedure "four" line 2) invoked from within "four"
This is because the stack trace between where the error occurred (inside four ) and where you caught it, there is only one procedure call.
If instead you caught the “next” error as follows:
catch {one} puts $::errorInfo
The stack trace between the catch statement and the error includes procs one , two , three and four . This leads to a stack trace as follows:
Yup, an error while executing "error "Yup, an error"" (procedure "four" line 2) invoked from within "four" (procedure "three" line 2) invoked from within "three" (procedure "two" line 2) invoked from within "two" (procedure "one" line 2) invoked from within "one"
So ... to match your example for test1 , if you redefined three as follows:
proc three {} { catch {four} puts $::errorInfo }
And you rated
if {[catch {one}]} { puts "Found an error" }
You might not see the “error found” because the body of three caught the error and printed a stack trace. A stack trace containing calls between the catch statement and the error - which (like my first example) consists of just calling four .
So where do you put your catch expressions.
In the corresponding note, you can re-throw the error by saving the stack trace if you want. Here's the new definition for three :
proc three {} { if {[catch {four} err]} { puts "Caught an error $err, re-throwing" error $err $::errorInfo } }
Now, with a second error, you will see the following:
tchsh% catch {one} Caught an error Yup, an error, re-throwing 1 tclsh% set ::errorInfo Yup, an error while executing "error "Yup, an error"" (procedure "four" line 2) invoked from within "four" (procedure "three" line 2) invoked from within "three" (procedure "two" line 2) invoked from within "two" (procedure "one" line 2) invoked from within "one"