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...