Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ERROR LOGGING

Status
Not open for further replies.

PM2000

Programmer
Aug 18, 2000
42
BM
HI,

I'm trying to log each error produced by my app. I want to log:

1. Err.description
2. The Class/Form name
3. The Function/Sub name


My code for a typical routine looks something like this

Function DoSomething()

Try
'Do stuff

Catch
LogError(err.Description, "form or class Name", "Function or sub name")
End try

End Function


The LogError will log the error in my database.

What I would like to be able to do is reduce my typing. Where I would normally have to type the name of the Form/Class and Function/Sub, I was wondering if this could be done automatically, like how err.description gets you the full description of the error. Me.text will get me my form name, but I cannot find (and suspect there may not be) a way to automatically determine the name of the routine or class.


Thanks
Peter
 
The method where the exception was raised is in the System.Exception object as the TargetSite property.

The class where the exception was raised is in the System.Exception object as the Source property.

You can get the assembly where the exception was raised by doing some reflection. I'm not a VB.NET guy, but I think you can do it like this: Me.GetAssembly.GetName()

Chip H.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top