E.V.I.C.T.  B.V.
Edwin Vermeer Information Communication Technology.
Google
 
Web SITESKINNER.COM



home / open source software / ExceptionHandler

Your browser does not support webstandards: please upgrade your browser before proceding.(klick here for more information about web standards)

ExceptionHandler

Handeling Errors, Exceptions and warnings is an undervalued part of programming. If you do it well, it could make your debugging life much easier.

Adding code for handeling Errors, Exceptions and Warnings should be:
1. Easy = Just add a dll, add 2 lines to install and uninstall, Add 4 lines of code to each sub
2. Generic = Handle all errors in the same way.
3. Tracable = You do not need an error stack. Just let the error float up in the procedure tree while adding information in each step.
4. Locatable = Use line numbers. The only disadvantage is that it will add 10% to your .exe file size. I find it strange that so litle source code uses line numbers. That is probably because it reminds people to much ot the old Basic versions.
5. Robust = Even handle GPF exceptions. (They are getting rare aren't they)

Credits: Large parts of the Exception hanler is from a publication by Thushan Fernando.

Click here to download the complete source code, the compiled DLL and the demo.

How you can use the EVICT_ExceptionHandler.dll

Private Sub Form_Load()
On Error GoTo ErrorHandler
1   InstallExceptionHandler Me, App, True
2   msgbox 1/0
3   Exit Sub
ErrorHandler:
4   HandleTheException "Demo :: Error in Form_Load() on line " & Erl() & " triggered by " & Err.Source & "   (Error " & Err.Number & ")" & vbCrLf & Err.Description, "Error in cmdException2_Click()", enumExceptionHandling_Exception
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error GoTo ErrorHandler
21   UninstallExceptionHandler
22   Exit Sub
ErrorHandler:
23   HandleTheException "Demo :: Error in Form_Unload() on line " & Erl() & " triggered by " & Err.Source & "   (Error " & Err.Number & ")" & vbCrLf & Err.Description, "Error in cmdException2_Click()", enumExceptionHandling_Exception
End Sub

Private Sub cmdCrash_Click()
On Error GoTo ErrorHandler
32   Call RaiseAnException(cmbException.ItemData(cmbException.ListIndex))
33   Exit Sub
ErrorHandler:
34   HandleTheException "Demo :: Error in cmdCrash_Click() on line " & Erl() & " triggered by " & Err.Source & "   (Error " & Err.Number & ")" & vbCrLf & Err.Description, "Error in cmdCrash_Click()", enumExceptionHandling_Exception
End Sub
 
Cool! Planet-source-code
Thums up! Get Firefox! Valid HTML 4.01! Valid CSS!