RAD Studio
ContentsIndex
PreviousUpNext
__try

Category 

Statements, Keyword extensions 

Syntax  

__try compound-statement handler-list__try
__try compound-statement termination-statement

Description 

The __try keyword is supported in both C and C++ programs. You can also use try in C++ programs. 

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 normal program flow is interrupted. The program begins a search for a handler that matches the exception. If the exception is generated in a C module, it is possible to handle the structured exception in either a C module or a C++ module. 

If a handler can be found for the generated structured exception, the following actions can be taken:

  • Execute the actions specified by the handler
  • Ignore the generated exception and resume program execution
  • Continue the search for some other handler (regenerate the exception)
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) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!