Exception Handling and Debugging
What's in this chapter?
The general principles behind exception handling
The Try…Catch…Finally structure for trapping exceptions
How to send exceptions to other code using the Throw statement
Obtaining information about an exception by using the exception object's methods and properties
Event logging and simple tracing, and how you can use these methods to obtain feedback about how your program is working
The wrox.com code downloads for this chapter are found at www.wrox.com/remtitle.cgi?isbn=9781118314456 on the Download Code tab. The code file name is MainWindow.xaml.vb and is located in the chapter 6 folder.
Production quality applications need to handle unexpected conditions. In .NET this is done with the structured exception syntax. When an unexpected condition arises .NET does not generate error codes. Instead when an unexpected condition occurs, the CLR creates a special object called an exception. This object contains properties and methods that describe the unexpected condition in detail and provide various items of useful information about what went wrong.
This chapter covers how structured exception handling works in Visual Basic. It discusses the common language runtime (CLR) exception handler in detail and illustrates some programming methods that are efficient when catching exceptions.