
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
376
|
Chapter 7: Exception Handling
See Also
See the “Exception Class” topic in the MSDN documentation; also see the classes
that derive from the
Exception class.
7.4 Handling Derived Exceptions Individually
Problem
You have an exception hierarchy that consists of a base exception class and multiple
derived exception classes. At some point in your code, you want to handle only one
System.ComponentModel.
InvalidEnumArgumentException
ArgumentException Thrown when an invalid enumeration value is
passed to a method.
System.
InvalidOperationException
SystemException Thrown when a method is called while the
object it resides in is in a state that makes it
illegal to call this method.
System.IO.IOException SystemException Thrown when a general I/O exception occurs;
you should throw a more derived exception.
System.MemberAccessException SystemException Thrown when a general error occurs while
using a class member; you should throw a
more derived exception.
System.MethodAccessException MemberAccessException Thrown when a general error occurs while
using a method member.
System.
NotFiniteNumberException
ArithmeticException Thrown when a double or single data type is
expected to have a finite number and instead
it contains NaN, +infinity, or - infinity.
System.
NotImplementedException
SystemException Thrown when ...