| View previous topic :: View next topic |
| Author |
Message |
garfwen Halfop
Joined: 12 Mar 2008 Posts: 61
|
Posted: Sun Jun 28, 2009 7:46 pm Post subject: Catch error |
|
|
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Jun 28, 2009 9:52 pm Post subject: |
|
|
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 |
|
 |
garfwen Halfop
Joined: 12 Mar 2008 Posts: 61
|
Posted: Wed Jul 01, 2009 7:05 am Post subject: |
|
|
| Thanks. |
|
| Back to top |
|
 |
|