Question

To grep the error on the screen though catch eg

   puts $c
   #error on terminal : can't read "c": no such variable

   catch {puts $c} err
   puts $err # value of err 1

Is there any way to catch actual error message in TCL apart from signal in variable err.

Was it helpful?

Solution

Yes. Read the ::errorInfo or ::errorCode global variables to get the stack trace and a machine-parsable "POSIX error" three-element list, correspondingly.

Since Tcl 8.5, it's also possible to pass a name of a dictionary to catch after the name of the variable to receive the result, and that dictionary will be populated by much of what can be obtained via "classic" error variables I described above, and more.

This is all explained in the catch manual page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top