Exception Handling

An exception has come to stand for almost any type of error, but that's not how the word was originally intended. For example, bugs are errors in the logic of your code, but they're not exceptions. Similarly, the term error is often reserved for a problem in user input—the user might have entered an out-of-bounds number, for example. However, you are supposed to handle such errors with validation code that checks input and other user actions without resorting to the special kind of code meant to handle exceptions.

Exceptions are not preventable in the same way as errors. They're the problems that occur because of runtime conditions—you might be out of memory, for example, or there might not be a disk in a drive.

In C#, as in ...

Get Microsoft® Visual C#® .NET 2003 Kick Start 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.