Throwing Exceptions

You may want to raise errors out of your procedures to indicate to callers that some exception has occurred. You might want to simply pass back a standard runtime exception provided by the .NET Framework, or you might want to create your own exception condition. In either case, you'll use the Throw keyword to raise the exception out of the current block.

NOTE

The Throw keyword works in much the same manner as the Err.Raise method in VB6.

Error-Handling Options

You can determine which exceptions you want to handle and which ones you want to raise back to your callers. When an exception occurs, your options include the following:

  • Do nothing at all. In this case, the .NET runtime will automatically raise the exception back out ...

Get ASP.NET Developer's JumpStart 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.