Mirage Source http://web.miragesource.net/forums/ |
|
Using OnError http://web.miragesource.net/forums/viewtopic.php?f=210&t=240 |
Page 1 of 1 |
Author: | Bradyok [ Tue Jul 04, 2006 10:02 pm ] |
Post subject: | Using OnError |
In my serverside HandleData i've tried to set up an error handling system. For every packet being recieved it sets CurrRunning to the packet name. Now what i want is for when it finds an error, to write it in the log. I'm not sure exactly how OnError works, just OnError Resume Next, but i'm sure someone can help me. |
Author: | funkynut [ Tue Jul 04, 2006 10:17 pm ] |
Post subject: | |
If running the the code after the error doesnt matter, make a label at the end of the sub e.g 'ErrorHandler:' ' HandleError:' then put 'OnError GoTo ErrorHandler' or what ever you called the lebel Btw, make sure you put exit sub or exit function before the lebel, otherwise if the code allows, it will run the error handler no matter what |
Author: | grimsk8ter11 [ Tue Jul 04, 2006 10:27 pm ] |
Post subject: | |
Code: Sub HandleData(Index As Long, Data As String) On Error GoTo Hell codecodecodecode Exit Sub 'stupid mis Hell: log code End Sub visual representation of what funky said. Or soemthing like this: Code: Sub HandleData(Index As Long, Data As String)
On Error Resume Next code code code code If Err.Number <> 0 Then 'can also amke thsi so it does specific things for each error. log code Err.Clear End If End Sub that will continue through the code and post the error at the end, incase things still need to be ran further on. |
Author: | Misunderstood [ Tue Jul 04, 2006 11:29 pm ] |
Post subject: | |
Quote: Sub Handledata
On error got Hell ...... exit sub Hell: Call errorHandler(err) End sub |
Author: | BigRed [ Wed Jul 05, 2006 3:09 pm ] |
Post subject: | |
Also keep in mind, On Error GoTo 0, is useful for stopping all error handling routines in the current procedure. |
Author: | Bradyok [ Wed Jul 05, 2006 3:54 pm ] |
Post subject: | |
Thanks alot. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |