14.7. Implement a Custom Exception Class

Problem

You need to create a custom exception class so that you can use the runtime's exception-handling mechanism to handle application-specific exceptions.

Solution

Create a serializable class that inherits the System.Exception class. Add support for any custom data members required by the exception, including constructors and properties required to manipulate the data members.

If you need to define a number of custom exceptions for use in a single application or library, you should define a single custom exception that extends System.Exception and use this as a common base class for all your other custom ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.