DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004

    I need a global error handling procedure

    [Originally posted by mad]

    Can anyone please tell me, how to add a global error handling procedure to the project? Adding "on error goto..." to a bigger project takes too much time... Thanks

  2. #2
    Join Date
    Aug 2004

    Re:I need a global error handling procedure

    [Originally posted by Tom]

    I wrote a vb program that adds error handling code to every sub and function.˙ I cannot give you the code but can point you in the right direction.

    The program I wrote scans through the .vbp file looking for forms, modules, etc... and modifies every function and sub routine so it includes the following code at the start and end of each.˙ I can also strip the code with the program by using the >>>>>>>>> and <<<<<<<<<.

    'Error Trapping *********
    If Not DevMode Then On Error GoTo slOnErr1002
    Dim slOnErrMsg As String

    'Your Code Here

    'Error Trapping *********
    Exit Sub
    SLErrChk "Form˙ - Sub SLErrChk ", Err, slOnErrMsg
    Resume Next

    To keep slOnErr1002 unique I use a counter so the next routine would be slOnErr1003.

    I then have a .bas file that I add to every program that includes the routines to display the error message and logs the error to a file.˙ Some of this code is as follows.

    Sub SLErrChk(xWhere, xErr, xslOnErrMsg)
    ˙ ˙ Dim xMsg As String
    ˙ ˙ xMsg = "Error # " + Str$(xErr) + " (" + Error$(xErr) + ") was trapped in " + xWhere + " - " + xslOnErrMsg
    ˙ ˙ LogIt xMsg˙ 'Sub Routine LogIt writes the message to a log file
    ˙ ˙ Msgbox xMsg
    ˙ ˙ Msgbox "If this error continues please email the application log file errors.log to you@yourdomain.com along with a description of the problem"
    ˙ ˙ If Msgbox("Resume..........", 4) = 6 Then
    ˙ ˙ ˙ ˙ Exit Sub
    ˙ ˙ End If
    ˙ ˙ End
    End Sub

    I use these routines on many projects and they work very well.˙ They have saved me many hours of effort on each project.˙ If you contact me direct I might be able to help some more.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.