|
-
May 7th, 2004, 08:53 AM
#1
Thread Starter
Frenzied Member
catching errors
when in a try..catch.., is it possible to capture the line number that the code is at when the catch happens? I'd like to do so for logging purposes.
-
May 7th, 2004, 09:57 AM
#2
Frenzied Member
exception.getobjectdata is supposed to return serializable data about the exception, but I don't know much about it. You could parse the exception.tostring text for the text starting with "line no...."
I'm not sure if it would help in an exe; since most comments are stripped out, I don't know if the line numbers there would necessarily match those in the IDE.
exception.targetsite.tostring will give you the sub that threw the exception.
-
May 7th, 2004, 10:14 AM
#3
Frenzied Member
Example
VB Code:
Try
'Code Here
Catch ex As Exception
Dim strErrMsg As String = ex.Message.ToString()
Dim strTrace As String = ex.StackTrace.ToString()
'Call your logging function
Call LogError(strErrMsg, strTrace)
End Try
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
May 7th, 2004, 10:29 AM
#4
You could also look into using the stack trace class:
http://msdn.microsoft.com/library/de...classtopic.asp
-
May 7th, 2004, 11:42 AM
#5
Thread Starter
Frenzied Member
that's exactly what I was looking for! thanks fellas!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|