I would guess one of two things are happening:
1 - You're calling "Stuff" from inside the constructure or your NNTP class.
With you constructing your NNTP class outside the try/catch, the exception
is being propigated.
2 - You have "Break on all Exceptions" turned on. This means each time an
exception is thrown, you break into the debugger. Look at this via
"Ctrl-Alt-E" at design time, and make sure the settings are all default.
There area also a few exception types that you really can't catch - for
example if you run out of memory, or run out of stack space, it's not always
possible to catch these. I really doubt you're running into that here
though.
--
Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP
http://www.coversant.com/blogs/cmullins
"Terry Olsen" <to******@hotmail.comwrote in message
news:u%****************@TK2MSFTNGP04.phx.gbl...
I'm not throwing an exception in an exception. Here's a snippet...
Public Class NNTP
Public Sub Stuff
..code removed for brevity
'Tell server that we're a reader
sw.WriteLine("MODE READER")
GetNntpResponse()
If rslt <201 And rslt <200 Then
ShutDown()
Throw New Exception(_NNTPServer & ": " & rsltStr)
End If
End Sub
End Class
From my main window, i'm calling it like this:
Dim nntp As New NNTP(ServerName)
Try
nntp.Stuff
Catch ex as Exception
msgbox(ex.message)
Exit Sub
End Try
However, when Sub Stuff throws the exception, the calling code isn't
catching it. Instead, it says that the thrown exception was unhandled.
If you know how to properly do this, i'd appeciate some pointers.
"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>
Terry
>>My calling code (in a different class) is wrapped in a Try/Catch block,
but it's not catching. Instead the IDE is highlighting the ThrowNew
Exception line in the class and saying it was unhandled.
maybe you are handling specific errors and the one you raise is not one
of them ?
IMHO it is foolish to throw a new exception this way
try
catch ex as exception
throw new exception("bla")
end try
i do not see the point of catching the error at all in the dll if you
want it to bubbel up to the caller, you could just let the chaining
mechanism handle this , errors are always chained
just as in VB6,
so if you write a handler in a top level of the chain the error will be
catched there with much less overhead and more information about the
origin
see my posting and the responses here
http://groups.google.nl/group/micros...0428fc2290c143
Michel
"Terry Olsen" <to
ls****@hotmail.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>>I have a class where I throw a new exception from a method
My calling code (in a different class) is wrapped in a Try/Catch block,
but it's not catching. Instead the IDE is highlighting the ThrowNew
Exception line in the class and saying it was unhandled.
Looking for some help.
Thanks!