Method Name

J

James

We currently use Try/Catch blocks to handle exceptions, and when an
exception occurs, we write it to the database with the method name and other
information about the exception. We're currently changing the method name
in every method and I'd like to get away from that. I found this:

Dim st As New System.Diagnostics.StackTrace
Dim sf As System.Diagnostics.StackFrame = st.GetFrame(0)
Response.Write(sf.GetMethod().Name)

....which works, but I'd prefer to have this all in one central function
instead of copied/pasted 50 times per page. Is there any good way of doing
what I want to do?

Thanks
 
B

Bruce Barker

well, you could write one LogError(ex) method, that did all the work, and
you'd only have to change the code once. future changes would be in the log
method. i typically log the stack trace, rather than the method name.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top