Exceptions Overview

At the base of all exception classes is System.Exception, which derives from System.Object.

Note

It is possible to throw a System.Object directly from System.Object, but doing so is not consistent with how exceptions are used in the CLR. In addition, the C# compiler doesn't allow it.

Most (if not all) of the exception classes derived from System.Exception do not add functionality, but they do provide a type so that errors can be filtered and handled in the correct context as discussed previously. Many classes are derived directly from System.Exception. A couple of classes that derive directly from System.Exception are IOException and WebException. IOException is thrown when an I/O error occurs (usually the result of an operation ...

Get .NET Common Language Runtime Unleashed 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.