Delphi / Object Pascal · Exception

EConvertError Exception

What does EConvertError Exception mean in Delphi / Object Pascal?

Indicates a string-to-value or object conversion failed - StrToInt on non-numeric text, StrToDate on a string that doesn't match the active locale's date format, or a failed Format/FormatFloat mask. It's one of the most common exceptions in data-entry code because the result depends on the runtime's locale settings, which can differ between the developer's machine and the user's.

EConvertError ExceptionDelphi (VCL) · Delphi (FireMonkey)

Condition

Indicates a string-to-value or object conversion failed - StrToInt on non-numeric text, StrToDate on a string that doesn't match the active locale's date format, or a failed Format/FormatFloat mask. It's one of the most common exceptions in data-entry code because the result depends on the runtime's locale settings, which can differ between the developer's machine and the user's.

Fix

Use the TryStrToInt/TryStrToFloat/TryStrToDate family instead of the raising variants wherever user input is involved, and validate format strings against the target machine's FormatSettings rather than assuming a fixed locale.

Related exception