41.11. Exceptions
Visual Studio 2008 has a sophisticated exception handler that provides you with a lot of useful information. Figure 41-15 shows the exception assistant dialog that appears when an exception is raised. In addition to providing more information, it also displays a series of actions. The Actions list varies depending on the type of exception being thrown. In this case, the two options are to view details of the exception or copy it to the clipboard.
Figure 41.15. Figure 41-15
If you select the View Detail action item from the exception, you are presented with a modal dialog that provides a breakdown of the exception that was raised. Figure 41-16 shows the attributes of the exception, including the StackTrace, which can be viewed in full by clicking the down arrow to the right of the screen.
Figure 41.16. Figure 41-16
Of course, there are times when exceptions are used to control the execution path in an application. For example, some user input may not adhere to a particular formatting constraint, and instead of using a regular expression to determine whether it matches, a parse operation has been attempted on the string. When this fails, it raises an exception, which can easily be trapped without stopping the entire application.
By default, all exceptions are ...
Get Professional Visual Studio® 2008 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.