Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error Handling
#1
Difficulty: ? - I don't know...not too hard, though.

Explanation: This error handler will give you a highly detailed error report for good error tracking. It reports: Time: Error Number (Description) at line (line) at event (Sub).

What you need: You need to download CodeSMART Big Grin

< SERVER-SIDE >

First of all, you need to go through and find all of the error handling that is already in place. So find all:

Code:
On Error GoTo

And delete those lines. Then go to the bottom of the subs that the error handling was in and delete the error handling section (this includes the Exit Sub with the label name, which is most likely ErrHandler, then the code after that, which is the AddLog line). Now...

Once you have CodeSMART installed, click "CodeSMART" in the menu. Go down to Error and Exception Handling and then click Insert Error Handlers. Now click the Schemes button, which is at the bottom left. Once in Schemes...

Click "Add" in the Error Handling Schemes box (left) and type in ErrCustom as the scheme name. In the Header and Footer box, type this in the Header (top box):

Code:
On Error GoTo ErrHandler

And in the Footer (bottom box) type this:

Code:
Exit {MemberType}

ErrHandler:

    ErrorHandle "{MemberType} {MemberName}"

Now at the bottom make sure that only Insert line numbers is checked and that the base number is 1 and the step number is 1.

Now click Scheme-To-Element Assignments. In the Defined Assignments box go through each item changing the Error handling scheme to ErrCustom.

Now X out of that and you should be back in the Insert Error Handlers window. Click the drop down box at the top and do Current Project. You should see all of the assignments saying ErrCustom after them and ErrCustom as your default scheme.

Now you may click Begin!

Now find:

Code:
ErrHandler:

         ErrorHandle "Sub HandleData"

And change that to:

Code:
ErrHandler:

         ErrorHandle "Sub HandleData (Packet " & Parse$(0) & ")"

Now it's time for the money maker...the ErrorHandle sub. At the bottom of modGeneral add:

Code:
Public Sub ErrorHandle(ByVal EventString As String)

    If Err.Number > 0 Then
        AddLog "Error: " & Err.Number & " (" & Err.Description & ") at line " & Erl & " in event " & EventString & ".", "errorlist.txt"
    End If

End Sub

And you should be finished! Now you have an exceptional error handling system in place for your server Wink

What to do before you code: You need to, for lack of a better word, "unlock" the server. You should get CodeSMART to remove all of the error handling code and then you can start programming. Then add all of the error handling code back in (and remove it from the class modules and the ErrorHandle sub) and you'll be good to go!

Make sure you post any problems you have Wink
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)