Results 1 to 9 of 9

Thread: How to filter the "Exception" message? (RESOLVED)

  1. #1

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200

    How to filter the "Exception" message? (RESOLVED)

    I'm using MsgBox(Exception.Message) to display the error, but when I use MsgBox(Exception.ToString) it displays more information about the error.

    Is there a way to get only the form and the code line from the Exception.ToString?


    Thanx.
    Last edited by AlvaroF1; Sep 24th, 2003 at 10:16 PM.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I think the StackTrace is what you are looking for. Try:
    MsgBox(Exception.StackTrace)

  3. #3

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200
    Sorry, it is not.

    Exception.StackTrace is = Exception.ToString - Exception.Message

    Id like to change this msgbox...



    to...




  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The stacktrace is the only thing with that info and sometimes it can be pretty long. I think if you want specific things out of it then you'll have to parse it and get what you need. There is no property or anything that returns just that part.

  5. #5

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What happened I thought you had posted a resolution?

  7. #7

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200
    I had, but it was not really working...

  8. #8
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Maybe this will help you out. I didn't study it, but it talks about the standard error messages and how to make a more robust system.

    http://www.ftponline.com/vsm/2003_11...tures/dollard/

  9. #9
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I know this is old but I recently discovered you can make individual stackframes from an Exceptions stacktrace object. Which means it handles the parsing for you.
    VB Code:
    1. Try
    2.             Dim x As Integer = 1
    3.             Dim y As Integer = 0
    4.             Dim z As Integer = x / y
    5.         Catch ex As Exception
    6.             'create a stacktrace object from the except to parse it
    7.             Dim st As New StackTrace(ex, True)
    8.             'this just shows the first stackframe but there could be many
    9.             Dim sf As StackFrame = st.GetFrame(0)
    10.             MsgBox(String.Format("{0} {1} {2}", ex.Message, IO.Path.GetFileName(sf.GetFileName), sf.GetFileLineNumber), MsgBoxStyle.Critical)
    11.         End Try
    I remembered this topic while answering another one.

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