Error handling

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.

Here is some demo code that will show you how to user the error handler:

One thought on “Error handling”

Leave a Reply

Playground of Edwin Vermeer