Click to See Complete Forum and Search --> : how to generate error on custom class instantiation??


Martin_SBT
July 26th, 2006, 01:04 PM
(asp.net with vb.net in VS2003)

I got a custom Class with a "Sub New" in it. That sub New contains code that make some calls to a COM dll component. In that sub New, i can catch the exception error messages using:

Try
eSession2.Connect()

Catch COMex As COMException

'Debug.WriteLine(comex.ErrorCode)
Debug.WriteLine(comex.Message)
'
sourcepage.logonerror = COMex.Message
Exit Sub

End Try

Lets say i instantiate my custom class in my webform1 by saying:

dim obj as new customClass

How can i generate in error in the sub New of my customClass that i could catch when i instantiate my class from webform1??

Does it make any sense??

Martin_SBT
July 26th, 2006, 01:43 PM
got it!

i followed informations found at the following link on how to throw exceptions and it works grrrrreat!

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconbestpracticesforhandlingexceptions.asp