Chapter 12. Exception Handling


It is common sense to take a method and try it. If it fails, admit it frankly and try another. But above all, try something.

Franklin Delano Roosevelt

O! throw away the worser part of it, And live the purer with the other half.

William Shakespeare

If they're running and they don't look where they're going

I have to come out from somewhere and catch them.

J. D. Salinger

And oftentimes excusing of a fault Doth make the fault the worse by the excuse.

William Shakespeare

O infinite virtue! com'st thou smiling from the world's great snare uncaught?

William Shakespeare

Objectives

In this chapter you will learn:

  • What exceptions are and how they are handled.

  • When to use exception handling.

  • To use TRy blocks to delimit code in which exceptions might occur.

  • To Throw exceptions to indicate a problem.

  • To use Catch blocks to specify exception handlers.

  • To use the Finally block to release resources.

  • The .NET exception class hierarchy.

  • Exception properties.

  • To create user-defined exceptions.

Outline

12.1 Introduction

12.2 Exception Handling Overview

12.3 Example: Divide by Zero Without Exception Handling

12.4 Example: Handling DivideByZeroExceptions and FormatExceptions

12.4.1 Enclosing Code in a try Block

12.4.2 Catching Exceptions

12.4.3 Uncaught Exceptions

12.4.4 Termination Model of Exception Handling

12.4.5 Flow of Control When Exceptions Occur

12.5 .NET Exception Hierarchy

12.5.1 Classes ApplicationException and SystemException

12.5.2 Determining Which Exceptions a Method Throws

12.6 Finally Block

12.7 Exception Properties

12.8 User-Defined Exception Classes

12.9 Wrap-Up



Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net