
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
398
|
Chapter 7: Exception Handling
something similar to this would be displayed:
System.Exception: The innerInner Exception.
at Chapter_Code.EH.MyMethod( ) in c:\book cs cookbook\code\test.cs:line 286
Notice that no exception other than the innerInner exception is displayed. This use-
ful technique gets to the root of the problem while filtering out all of the other outer
exceptions that you are not interested in.
See Also
See the “Error Raising and Handling Guidelines” and “Exception Class” topics in the
MSDN documentation.
7.13 Creating a New Exception Type
Problem
None of the built-in exceptions in the .NET Framework provide the implementation
details that you require for an exception that you need to throw. You need to create
your own exception class that operates seamlessly with your application, as well as
other applications. Whenever an application receives this new exception, it can
inform the user that a specific error occurred in a specific component. This report
will greatly reduce the time required to debug the problem.
Solution
Create your own exception class. To illustrate, let’s create a custom exception class,
RemoteComponentException, that will inform a client application that an error has
occurred in a remote server assembly.
Discussion
The exception hierarchy starts with ...