Project Wide Error Handling in VB.Net

eric13

Active member
Joined
May 25, 2006
Messages
30
Programming Experience
3-5
I want to log errors that happen in our application. Is it possible to set up general error handling for a whole project without having to use try catch blocks in every function or method?

Coming from foxpro...we set up a error handling in the main start up program like this,

on error
do vfp_error with error(),message(),message(1),program(),lineno()


On an error this would show a custom error form and log the error to a file project wide. We then handled specific methods using local error handling if we needed.
 
VB 2005 already provides a mechanism for this in the UnhandledException application event. The problem with using a global exception handler is that you can't then continue from where the exception occurred. If you want to do that, which you should in many circumstances, then you need to use a Try/Catch block specific to that section of code.

Exception handling is part of writing good code. Don't try to avoid it, but try to make it as efficient as possible, like everything.
 
Back
Top