Results 1 to 5 of 5

Thread: catching errors

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    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.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    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.

  3. #3
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Example
    VB Code:
    1. Try
    2.    'Code Here
    3. Catch ex As Exception
    4.    Dim strErrMsg As String = ex.Message.ToString()
    5.    Dim strTrace As String = ex.StackTrace.ToString()
    6.  
    7.    'Call your logging function
    8.    Call LogError(strErrMsg, strTrace)
    9. End Try
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  4. #4

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    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
  •  



Click Here to Expand Forum to Full Width