|
-
Sep 24th, 2003, 03:17 PM
#1
Thread Starter
Addicted Member
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.
-
Sep 24th, 2003, 03:23 PM
#2
I think the StackTrace is what you are looking for. Try:
MsgBox(Exception.StackTrace)
-
Sep 24th, 2003, 03:43 PM
#3
Thread Starter
Addicted Member
-
Sep 24th, 2003, 03:47 PM
#4
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.
-
Sep 29th, 2003, 12:05 PM
#5
Thread Starter
Addicted Member
-
Sep 29th, 2003, 12:37 PM
#6
What happened I thought you had posted a resolution?
-
Sep 29th, 2003, 01:51 PM
#7
Thread Starter
Addicted Member
I had, but it was not really working...
-
Oct 3rd, 2003, 03:58 PM
#8
PowerPoster
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/
-
Dec 1st, 2003, 11:25 AM
#9
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:
Try
Dim x As Integer = 1
Dim y As Integer = 0
Dim z As Integer = x / y
Catch ex As Exception
'create a stacktrace object from the except to parse it
Dim st As New StackTrace(ex, True)
'this just shows the first stackframe but there could be many
Dim sf As StackFrame = st.GetFrame(0)
MsgBox(String.Format("{0} {1} {2}", ex.Message, IO.Path.GetFileName(sf.GetFileName), sf.GetFileLineNumber), MsgBoxStyle.Critical)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|