Delphi / Object Pascal · Exception

Runtime Error 201: ERangeError

What does Runtime Error 201: ERangeError mean in Delphi / Object Pascal?

A value was assigned that falls outside the declared range of its type, most often an array index or an ordinal type with a restricted range, and range checking ($R+) was enabled when the assignment happened.

Runtime Error 201: ERangeErrorDelphi (VCL) · Delphi (FireMonkey)

Condition

A value was assigned that falls outside the declared range of its type, most often an array index or an ordinal type with a restricted range, and range checking ($R+) was enabled when the assignment happened.

Fix

Check the value against the type's declared bounds before the assignment. Range checking is a compile-time switch; if it is off in release builds, the same bad value will not raise this error there, it will simply corrupt memory instead, which is worse, so treat this as a bug to fix, not a check to disable.

Pending source verification. Not yet checked against official documentation.

Related exception