ESubstringRangeError Exception

Exception→ESubstringError→ESubstringRangeError

type ESubstringRangeError = class(ESubstringError);

An index, a count or a window outside the text.

Raised when a range check fails.

Examples

Mid with a count past the end raises.

delphi
uses Substr;

procedure Example;
var Raised: Boolean;
begin
    Raised := False;
    try
        Assert(Substring('abc').Mid(2, 5).IsEmpty);
    except
        on ESubstringRangeError do Raised := True;
    end;
    Assert(Raised);
end;