This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

need an error checking routine

Old posts that have not been replied to for several years.
Locked
P
PeTrArChY

Post by PeTrArChY »

I saw an error checking routine one time that really impressed me but I didn't write it down and now I can't remember what it was for the life of me. Anyway, what it did was catch errors in a tcl script, output them to the party line and then just not load that script, it wouldn't crash the bot.

I know that it was done using catch but can anyone help me with some code for this? I've been pulling my hair out for days trying to figure it out.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

It's probably a replacement "source" command. I wrote one once, it's pretty simple. Rename the old source command to "old_source" or something, then make a new source command that does catch {old_source $scriptname} and reports errors.
P
PeTrArChY

Post by PeTrArChY »

yeah, it did sort of replace the source command but it was really just a catch for the source. I've got it catching the error so that it doesn't crash the bot, I am just not sure how to show the error in the party line.

<font size=-1>[ This Message was edited by: PeTrArChY on 2002-01-09 08:17 ]</font>
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The simplest method to show it in the partyline, is to issue a "putlog" with the variable storing the info.

I am wondering if you where on about an alternative to eggdrops timer command? As that only spits out "error in timerXXXX"?
P
PeTrArChY

Post by PeTrArChY »

ok, the putlog is working ... thanks

now the only problem is I don't know what variable stores the error message. Anybody?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

EG

Code: Select all

catch {unknown_command} var1
The error msg is now stored in "var1"
P
PeTrArChY

Post by PeTrArChY »

this is what I finally came up with. It shows the error just like it normally would but it doesn't crash the bot.

Code: Select all

if { [catch {source scripts/dice.tcl}] } { putlog "Error in dice.tcln $errorInfo" }
just change dice.tcl with whatever script you are loading in both places.

Thanks for your help guys :smile:
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

I have a script that does what I was talking about earlier. That way you can use 'source' just like always and it still does the error catching and logging.

http://home.dal.net/stdragon/eggdrop/safesource.tcl

Just do: source scripts/safesource.tcl before you load any other scripts.
j
jedis

Post by jedis »

It would be nice if this was included with eggdrop by default, either via an option in the config to turn on, or the TCL included. I can't count the times I crashed my bot while trying to get a tcl working properly.
Locked