Book Image

Learning .NET High-performance Programming

By : Antonio Esposito
Book Image

Learning .NET High-performance Programming

By: Antonio Esposito

Overview of this book

Table of Contents (16 chapters)
Learning .NET High-performance Programming
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exception handling


Exception handling is the black art of doing something to repair an unpredicted error or malfunction. Within CLR, anytime something happens outside our prevision, such as setting an Int16 typed variable with a value outside valid ranges, the CLR will handle such an event by itself, creating an instance of an Exception class and breaking the execution of our code, trying instead to find some other code able to handle (a.k.a catch) such an exception.

Any Exception class is populated with all useful details regarding what just happened, like a simplified error text (within the Message property), the StackTrace that explains exactly the whole method call hierarchy, and other details. Often, instead of a simple Exception class, an inheritance child is instantiated to collect specific additional details or simply to define the kind of exception just raised. Indeed, setting an outranged value within an Int16 typed variable will raise an OverflowException event in place of a simple...