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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top