SUNiNET - Your Eggdrop & TCL resources site
[ Home Eggdrop TCL Links About ]

Guide to TCL scripting for Eggdrop 1.6


[ Previous ] [ Index ] [ Next ]


12.7 Catching errors

A very usefull command is catch. With this command you can execute something and catch the error, if there is one and prevent your script from crashing.
Under some circumstances it just might be easier to just use the catch command instead of a bunch of checks.
The syntax of a catch command is catch <command>.

The <command> is what you want to execute, including the parameters.
Just make it exactly how you would've executed it if you weren't using the catch command.

The catch command will return a 0 if there were no errors and a positive number otherwise.

For example if you were to unbind the dcc command die, it is better to do it like catch { unbind dcc n die *dcc:server:die }, because if your bot is not connected to IRC you'd have to use catch { unbind dcc n die *dcc:die }.
This way you can easily unbind the die command without trouble, because if you try to unbind a command that doesn't exist your bot will give an error and crash.


[ Previous ] [ Index ] [ Next ]


Design & Graphics by Shawn Borton
Copyright © 2000-2005 Marijn van Zon