Error Logging

Aspnot

Active member
Joined
Feb 24, 2004
Messages
37
In an application that I am writing, I am logging my errors to SQL Server and if that fails to a HTM file.

I have an error handling class that has a property for ClassModule and Routine. Currently, when an error happens in a Try...Catch block, I have to set these properties and then call the HandleError routine. I would like to use a method similar to the one used by Microsoft here.

How can I get the class module that handles the errors to know what the ClassModule and Routine variables should be if I use this method?

The only thing I can think of is to use the Call Stack and parse it out. This seems kinda ugly. I would think that there is some sort of way to get this information since I am sure that I am not the only one who wants this information to be logged with errors.


PS - Yes I do plan to handle certain errors individually, but for other errors, I just plan to have the Try...Catch block Throw the error again.

Any guidance would be greatly appreciated.
 
well, what I do to handle global error not handled in a try catch i Use this.
In the main assembly I add as a class variable accesible by all the routines this

C#:
AppDomain AppDom = AppDomain.CurrentDomain;

then in the Load Event of the form

C#:
AppDom.UnhandledException += new UnhandledExceptionEventHandler(this.AppDomHandler);
Application.ThreadException +=new ThreadExceptionEventHandler(this.ThreadHandler);

every time an error ocurrs in the application this will catchem if theyre not inside a try catch, remember to create the Handler routines

Cheers!!!!
 
I can handle the UnhandledExceptions. What I am looking for is the class module that has my error handling code to be able to log what form/class the error occurred in and what routine it occurred in.
 
well ive never done that, but I know that the System.Reflection namespace can help you
 
I have looked through the System.Reflection namespace for hours and havent been able to narrow it down to what I am looking for.

Anyone ever done this that can point me in the right direction?
 
aspnot, I have also been trying to do this lately, Im tryed a number of ideas, with mixed success. Check out these threads for more information, and let me know if you find/solve anything new...

http://www.computerhelp.forum/showthread.php?t=83480

Im planning to do some more work on this next week on my current project, so we should work together on this to solve this problem once and for all.
 
Back
Top