Creating and Using Custom Exceptions

Implement error handling in the user interface.

  • Create and implement custom error messages.

  • Create and implement custom error handlers.

  • Raise and handle errors.

The exception classes provided by the .NET Framework, combined with the custom messages created when you create a new Exception object to throw or rethrow exceptions, should suffice for most of your exception handling requirements. In some cases, however, you might need exception types that are specific to the problem you are solving.

EXAM TIP

Using ApplicationException as a Base Class for Custom Exceptions Although you can derive custom exception classes directly from the Exception class, Microsoft recommends that you derive custom exception classes ...

Get MCAD/MCSD.NET Training Guide (Exam 70-316): Developing and Implementing Windows®-Based Applications with Microsoft® Visual C#™ .NET and Microsoft® Visual Studio® .NET 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.