Oct. 11, 2008, 11:31 p.m.
posted by irds
ExceptionsIn order to provide a common, rich, easily programmed, and difficult to ignore way of signaling and handling errors, the .NET Framework supports structured exception handling. A caller places an exception handler on the stack at the point at which he wants to catch the error, using the try–catch syntax of his programming language. A called function wanting to signal an error creates an object of class System.Exception (or one derived from it) containing information about the error and throws it. The CLR searches up the call stack until it finds a handler for the type of exception that was thrown, at which time the stack is unwound and control transferred to the catch block, which contains the error handling code. The class System.Exception is the base class from which all exception objects derive. It contains such basic information as a message provided by the thrower and the stack trace at which the exception took place. The class System.SystemException derives from it, and all system-provided exceptions derive from that. This allows a programmer to differentiate between system-provided and programmer-built exceptions. The system-provided exceptions in Figure were felt to be common enough to occupy the base System namespace and are covered in this volume of the .NET Framework Standard Library Annotated Reference. Many more specialized exception classes live in subordinate namespaces.
|
- Comment