HomeDelphiDelphi Error – E2127 ‘GOTO %s’ leads into or out of TRY statement

Delphi Error – E2127 ‘GOTO %s’ leads into or out of TRY statement

Delphi Compiler Error

E2127 ‘GOTO %s’ leads into or out of TRY statement

Reason for the Error & Solution

The GOTO statement cannot jump into or out of an exception handling statement.

program Produce;

label 1, 2;

begin
  goto 1;
  try
1:
  except
    goto 2;
  end;
2:
end.

Both GOTO statements in the above code are incorrect. It is not possible to jump into, or out of, exception handling blocks.

The ideal solution to this problem is to avoid using GOTO statements altogether, however, if that is not possible you will have to perform more detailed analysis of the program to determine the correct course of action.

Share:

Leave a Reply

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...