RAD Studio
ContentsIndex
PreviousUpNext
try

Category 

Statements, C++-Specific Keywords 

Syntax  

try compound-statement handler-list

Description 

The try keyword is supported only in C++ programs. Use __try in C programs. C++ also allows __try

A block of code in which an exception can occur must be prefixed by the keyword try. Following the try keyword is a block of code enclosed by braces. This indicates that the program is prepared to test for the existence of exceptions. If an exception occurs, the program flow is interrupted. The sequence of steps taken is as follows:

  • The program searches for a matching handler
  • If a handler is found, the stack is unwound to that point
  • Program control is tranferred to the handler
If no handler is found, the program will call the terminate function. If no exceptions are thrown, the program executes in the normal fashion.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!