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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.