Information Technology Reference
In-Depth Information
The try Statement
The
try
statement allows you to designate blocks of code to be guarded for exceptions, and to
supply code to handle those exceptions. The
try
statement consists of three sections, as shown
in Figure 11-1.
•The
try
block
contains the code that is being guarded for exceptions.
The
catch
clauses section
contains one or more
catch
clauses
. These are blocks of code to
handle the exceptions. They are also known as
exception handlers
.
The
finally
block
contains code to be executed under all circumstances, whether or not
an exception is raised.
Figure 11-1.
Structure of the try statement