Kerri,
In addition to Joe's comments, be careful with throwing an existing
exception in VB.NET. Your stack trace may be reset.
If I have:
Try
SomethingThatThrowsAnException()
Catch ex As Exception
' log the exception
Throw
End Try
When you simple use the Throw statement as I have, the stack trace will be
maintained from inside of SomethingThatThrowsAnException where the exception
really happened.
However if I had used:
Catch ex As Exception
' log the exception
Throw ex
End Try
The Stack Trace will be reset to this routine, loosing the fact that it
originally occurred inside of SomethingThatThrowsAnException.
Alternatively we can:
Catch ex As Exception
' log the exception
Throw New Exception(ex)
End Try
Which will create a new exception with a reference to the original
exception, as the inner exception.
Hope this helps
Jay
"Kerri" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
Hi,
I am new to .NET
In my Error Logic on my Aspx pages when an error happens
it hits my catch statement where I throw an Exception.
My question is :
what is the difference between Thwo Exception and Throw
New Exception?
Anq when should either be used?
Thanks,
Kerri.