Free mag vol1 | Page 342

CHAPTER 7  UNDERSTANDING STRUCTURED EXCEPTION HANDLING Figure 7-5. Viewing exception details  Source Code The ProcessMultipleExceptions project is included under the Chapter 7 subdirectory. Summary In this chapter, you examined the role of structured exception handling. When a method needs to send an error object to the caller, it will allocate, configure, and throw a specific System.Exception derived type via the C# throw keyword. The caller is able to handle any possible incoming exceptions using the C# catch keyword and an optional finally scope. When you are creating your own custom exceptions, you ultimately create a class type deriving from System.ApplicationException, which denotes an exception thrown from the currently executing application. In contrast, error objects deriving from System.SystemException represent critical (and fatal) errors thrown by the CLR. Last but not least, this chapter illustrated various tools within Visual Studio that can be used to create custom exceptions (according to .NET best practices) as well as debug exceptions. 280