Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error handling

Status
Not open for further replies.

Tatto

Programmer
Aug 24, 2009
6
0
0
BR
Hi.

I'm new in tcl programming, and I'm looking for a better way to handle errors.

Actually, I use "catch {}" in critical areas and if it returns 1, a function to treat this error is called.
This function may receive arguments such as important information about the state of the program, and prints out comments about the error (with an "error" command instead of "return -code"). The only problem is that the program ends when it finds an error.
Is there any other way to do it better?

Thanks.
 
I don't follow. The "catch ..." statement is specifically designed to allow error handling without aborting the script. Maybe you could elaborate more on what you're experiencing.

_________________
Bob Rashkin
 
I use catch to verify if a have an error, but I also want to use the error stack to find out exactly where the error occured (in which line, procedure...).
Is there any other way to access this information?
 
What do you see if you gets stderr?

_________________
Bob Rashkin
 
Apparently, I can't read from stderr :

channel "stderr" wasn't opened for reading

 
What if you open it?

_________________
Bob Rashkin
 
Never mind, that was too glib. I found this at the Tcl Wiki:
Someone mentioned on comp.lang.tcl that it took them a while to understand that when you use catch and supply a variable, the output from the command that would go to stderr ends up in the variable.
I take that to mean that you should have all the information in whatever variable you supply to catch <expression> <variable>

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top