Name
Except Keyword
Syntax
tryStatements... exceptStatements... end; tryStatements... exceptException handlers... end;
Description
The except
keyword is part of a
try-except block. The try part
lists statements that Delphi executes, and the
except part lists exception handlers, which Delphi
executes only if a statement in the try part
raises an exception.
The try-except statement has
two varieties:
The first kind has a list of statements in the
exceptpart. If any exception occurs, Delphi executes the statements in theexceptpart. If the statements do not raise another exception, the program continues with the statement following the end of thetry-exceptstatement.The second kind has a list of exception handlers in the
exceptpart. Each exception handler starts with theondirective and specifies an exception class. Theexceptpart traps only the exceptions listed in the exception handlers. The last handler can be anelseclause to trap all other exceptions. If an exception does not match any of the listed exception handlers, and theexceptpart has noelseclause, Delphi reraises the exception (just as though you had usedelseraiseas the last exception handler).
For examples and more information about exception handlers, see the
try keyword.
See Also
| Finally Keyword, On Directive, Raise Keyword, Try Keyword |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access