Writing Code to Handle Exceptions

Users of your program are not likely to be developers or Visual Studio users. Therefore, to make your application more robust, you’ll want to add exception-handling code to control its behavior after an exception is thrown. Good exception-handling code should do the following:

  • Make sure the error is logged accurately, so you know which method call actually caused the exception.

  • Depending on the severity of the exception, you may want to display a message for the end user. This message should be written so that the user can understand it, and if necessary it should provide instructions on how to resolve the problem.

In a complex application, you may have objects that call other objects in a nested manner. It is ...

Get Special Edition Using Microsoft® Visual Basic® .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.