-
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
-
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
slOnErr1002:
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.
tom@slsoft.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks