Delphi / Object Pascal · Exception

EListError Exception

What does EListError Exception mean in Delphi / Object Pascal?

Raised when code accesses a TList, TStrings, or TStringList item with an out-of-range index, adds a duplicate string to a TStringList whose Duplicates property is dupError, or inserts into a sorted TStringList at a position that would break the sort order. It's the general list-integrity exception underlying most TStrings-descendant misuse.

EListError ExceptionDelphi (VCL) · Delphi (FireMonkey)

Condition

Raised when code accesses a TList, TStrings, or TStringList item with an out-of-range index, adds a duplicate string to a TStringList whose Duplicates property is dupError, or inserts into a sorted TStringList at a position that would break the sort order. It's the general list-integrity exception underlying most TStrings-descendant misuse.

Fix

Bounds-check Count before indexing, check IndexOf before adding when duplicates matter, and call Add instead of Insert on sorted lists so the list picks the correct position itself.

Related exception