Delphi Error – E2125 EXCEPT or FINALLY expected

Delphi Compiler Error

E2125 EXCEPT or FINALLY expected

Reason for the Error & Solution

The compiler was expecting to find a FINALLY or EXCEPT keyword, during the processing of exception handling code, but did not find either.

program Produce;

begin
  try
  end;
end.

In the code above, the ‘except’ or ‘finally’ clause of the exception handling code is missing, so the compiler will issue an error.

program Solve;

begin
  try
  except
  end;
end.

By adding the missing clause, the compiler will be able to complete the compilation of the code. In this case, the ‘except’ clause will easily allow the program to finish.