G
Guest
Following guidelines from MSDN, I created my custom exceptions by inheriting
from ApplicationException. Unlike the .NET framework exceptions, I cannot set
my Message property in the first line of the constructor like this:
Class CustomException(Message as string)
MyBase.New(Message)
End Class
I cannot do this because I need to do some other stuff before I calculate
the Message property. But after that line right there, there is no way to set
the Message property.
I tried overriding the ToString() property like this:
Overrides Function ToString() as string
Return "My custom message"
End Function
This doesn't work, when use the "Throw" statement on an instance of my
CustomException. Instead the exception window just says "Error in the
application".
Any ideas on what I am doing wrong? (TIA)
from ApplicationException. Unlike the .NET framework exceptions, I cannot set
my Message property in the first line of the constructor like this:
Class CustomException(Message as string)
MyBase.New(Message)
End Class
I cannot do this because I need to do some other stuff before I calculate
the Message property. But after that line right there, there is no way to set
the Message property.
I tried overriding the ToString() property like this:
Overrides Function ToString() as string
Return "My custom message"
End Function
This doesn't work, when use the "Throw" statement on an instance of my
CustomException. Instead the exception window just says "Error in the
application".
Any ideas on what I am doing wrong? (TIA)