egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Catch error

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
garfwen
Halfop


Joined: 12 Mar 2008
Posts: 61

PostPosted: Sun Jun 28, 2009 7:46 pm    Post subject: Catch error Reply with quote

Hello

Code:

<Eggdrop> [XX:XX] Tcl error [my_proc]: ::mysql::sel/db server: MySQL server has gone away


is there any way to catch this error? and execute something when it catches?

Thank you
GaRfWeN
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Jun 28, 2009 9:52 pm    Post subject: Reply with quote

Use the "catch" command with each ::mysql::* command? (works for any other command that would throw an error, as well).

Workflow would be something like this:
Code:
if {[catch {::mysql::sel "SELECT * FROM `Yourtable`" -list} result]} {
  putlog "An error occured while retrieving data from `Yourtable`. The error was \"$result\"."
} {
  putlog "Retrieved data from `Yourtable`:"
  foreach item $result {
    putlog "data: [join $item ", "]"
  }
}

In the case of an error, you'll also find extended information on the error in the ::errorInfo and ::errorCode variables (putlog $::errorCode or such).
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
garfwen
Halfop


Joined: 12 Mar 2008
Posts: 61

PostPosted: Wed Jul 01, 2009 7:05 am    Post subject: Reply with quote

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber