Delphi Compiler Error
E2126 Cannot BREAK, CONTINUE or EXIT out of a FINALLY clause
Reason for the Error & Solution
Because a FINALLY clause may be entered and exited through the exception handling mechanism or through normal program control, the explicit control flow of your program may not be followed. When the FINALLY is entered through the exception handling mechanism, it is not possible to exit the clause with BREAK, CONTINUE, or EXIT – when the finally clause is being executed by the exception handling system, control must return to the exception handling system.
program Produce; procedure A0; begin try (* try something that might fail *) finally break; end; end; begin end.
The program above attempts to exit the finally clause with a break statement. It is not legal to exit a FINALLY clause in this manner.
program Solve; procedure A0; begin try (* try something that might fail *) finally end; end; begin end.
The only solution to this error is to restructure your code so that the offending statement does not appear in the FINALLY clause.