By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,603 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,603 IT Pros & Developers. It's quick & easy.

IDE debugging question

P: n/a
I'm hoping there's a way to do this, because my present technique
wastes a lot of time.

Suppose I have this console app:

Module Module1

Sub Main()
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
End Sub

End Module

When I run this from within the IDE, obviously execution will halt with
a divide by zero exception when attempting to assign to c. The
dialogbox presented to me tells me the exception type, and 'Additional
information' which is in fact the exception's Message property. The
buttons I can click are Break and Continue. If I click Continue,
execution ends, which is fine.

If I click Break, I am now in debug mode in the IDE and can I have the
command line and all the usual debug tools, so I can (in this example)
examine b and see that it is indeed zero, and understand why I got my
exception.

However. In a more real-world example, some of the information that
would help debug would be *in the Exception that has just been thrown*.
My question therefore is:

Once I have clicked Break and entered debug mode, is there any way to
obtain / interrogate / anything! the Exception which got me here?

--
Larry Lard
Replies to group please

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
Larry,

Sorry if I miss your point here. Can you not use the Try Catch block, and
have it show you the exception?

ie.

Try
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
Catch ex as exception
msgbox(ex.message)
End Try

Rgds,

Phil

"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I'm hoping there's a way to do this, because my present technique
wastes a lot of time.

Suppose I have this console app:

Module Module1

Sub Main()
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
End Sub

End Module

When I run this from within the IDE, obviously execution will halt with
a divide by zero exception when attempting to assign to c. The
dialogbox presented to me tells me the exception type, and 'Additional
information' which is in fact the exception's Message property. The
buttons I can click are Break and Continue. If I click Continue,
execution ends, which is fine.

If I click Break, I am now in debug mode in the IDE and can I have the
command line and all the usual debug tools, so I can (in this example)
examine b and see that it is indeed zero, and understand why I got my
exception.

However. In a more real-world example, some of the information that
would help debug would be *in the Exception that has just been thrown*.
My question therefore is:

Once I have clicked Break and entered debug mode, is there any way to
obtain / interrogate / anything! the Exception which got me here?

--
Larry Lard
Replies to group please

Nov 21 '05 #2

P: n/a

Sure, if I *had* a Try Catch block. But sometimes (and keep this one
just between us :)) I write code that isn't wrapped in a Try. Shocking,
I know. My present technique - the one which wastes time - is that when
I *do* get an unexpected exception, I then end execution, wrap the
relevant bit in a Try, then run again and follow the same code path to
get to that place, only this time I am waiting to Catch the exception.

I was hoping I could avoid having to make myself habitually put
everything in a Try block. I've changed coding practice in the past, so
it's possible - but I'd rather be able to just access the exception
that's made me break execution.
Phil wrote:
Larry,

Sorry if I miss your point here. Can you not use the Try Catch block, and
have it show you the exception?

ie.

Try
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
Catch ex as exception
msgbox(ex.message)
End Try

Rgds,

Phil

"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I'm hoping there's a way to do this, because my present technique
wastes a lot of time.

Suppose I have this console app:

Module Module1

Sub Main()
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
End Sub

End Module

When I run this from within the IDE, obviously execution will halt with
a divide by zero exception when attempting to assign to c. The
dialogbox presented to me tells me the exception type, and 'Additional
information' which is in fact the exception's Message property. The
buttons I can click are Break and Continue. If I click Continue,
execution ends, which is fine.

If I click Break, I am now in debug mode in the IDE and can I have the
command line and all the usual debug tools, so I can (in this example)
examine b and see that it is indeed zero, and understand why I got my
exception.

However. In a more real-world example, some of the information that
would help debug would be *in the Exception that has just been thrown*.
My question therefore is:

Once I have clicked Break and entered debug mode, is there any way to
obtain / interrogate / anything! the Exception which got me here?

--
Larry Lard
Replies to group please


Nov 21 '05 #3

P: n/a
Tym
On 28 Jul 2005 10:48:57 -0700, "Larry Lard" <la*******@hotmail.com>
wrote:
Sub Main()
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
End Sub


What's wrong with
Sub Main()
On Error Goto Error_Trap
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b

Exit Sub
Error_Trap:
Select Case Err.Number
Case 11
'Divide by Zero Error
Msgbox "You've tried to divide by Zero!"
'Obviously you can display any relevant information _
here about variables....
Error.Clear
Case Else
MsgBox Err.Number & ": " & Err.Description & " " _
& Err.Source
Err.Clear
End Select
End Sub

---
Tym

Please do not adjust your brain, there is a fault with reality
Nov 21 '05 #4

P: n/a
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
.. . .
However. In a more real-world example, some of the information that
would help debug would be *in the Exception that has just been
thrown*.


And that's exactly what you get handed to you in an Exception Handler.

Try
c = 1 / 0
Catch ex As DivideByZeroException
MsgBox( ex.Message )
Catch ex As Exception
MsgBox( "Did anyone get the number of that truck?" _
& vbCRLF & ex.ToString() _
)
End Try

HTH,
Phill W.
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.