7.2. The Role of .NET Exception Handling
Prior to .NET, error handling under the Windows operating system was a confused mishmash of techniques. Many programmers rolled their own error-handling logic within the context of a given application. For example, a development team could define a set of numerical constants that represented known error conditions, and make use of them as method return values. By way of an example, consider the following partial C code:
/* A very C-style error trapping mechanism. */ #define E_FILENOTFOUND 1000 int SomeFunction() { // Assume something happens in this function // that causes the following return value. return E_FILENOTFOUND; } void main() { int retVal = SomeFunction(); if(retVal == E_FILENOTFOUND) printf("Cannot ...
Get Pro C# 2010 and the .NET 4 Platform, Fifth Edition 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.