* Implement ListIndexError

(cherry picked from commit 8fb39925eb)
This commit is contained in:
Michaël Van Canneyt 2023-11-09 11:43:19 +01:00 committed by marcoonthegit
parent 28d9c6ce56
commit fc6b11720a
5 changed files with 35 additions and 6 deletions

View File

@ -133,11 +133,7 @@ type
EMethodNotFound = class(EFilerError);
EInvalidImage = class(EFilerError);
EResNotFound = class(Exception);
{$ifdef FPC_TESTGENERICS}
EListError = fgl.EListError;
{$else}
EListError = class(Exception);
{$endif}
EListError = {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}SysUtils.EListError;
EBitsError = class(Exception);
EStringListError = class(Exception);
EComponentError = class(Exception);

View File

@ -563,6 +563,21 @@ ResourceString
SMsgDlgYes = '&Yes';
SMsgDlgYesToAll = 'Yes to a&ll';
// Constants for Delphi compatibility
sAttributeExists = 'Attribute ''%s'' already exists';
sDeviceExists = 'Device ''%s'' already exists';
sCannotManuallyConstructDevice = 'Manual construction of TDeviceInfo is not supported';
SArgumentOutOfRange = 'Argument out of range';
StrNoClientClass = 'The client cannot be an instance of the class %s';
SListIndexErrorExt = 'List index out of bounds (%0:d). %2:s object range is 0..%1:d';
{ Classes observer support }
SErrNotIObserverInterface = 'Interface is not an IObserver interface';
SErrUnsupportedObserver = 'Observer type not supported';
SErrOnlyOneEditingObserverAllowed = 'Only one editing link observer is allowed';
SErrObserverNoSinglecast = 'No singlecast observer interface found';
SerrObserverNoMulticastFound = 'No multicast observer interface (%d) found';
SErrObserverNotAvailable = 'Observer type (%d) not available';
implementation

View File

@ -147,6 +147,7 @@ const
SFullpattern = 'Couldn''t match entire pattern string. Input too short at pattern position %d.';
SPatternCharMismatch = 'Pattern mismatch char "%s" at position %d.';
SAMPMError = 'Hour >= 13 not allowed in AM/PM mode.';
SErrListIndexExt = 'List index out of bounds (%d): %s object range is 0..%d';
SShortMonthNameJan = 'Jan';
SShortMonthNameFeb = 'Feb';

View File

@ -247,6 +247,7 @@ type
EInvalidOpException = class(Exception);
ENoConstructException = class(Exception);
EListError = Class(Exception);
EOperationCancelled = class(Exception);
@ -260,7 +261,7 @@ type
procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
procedure Abort;
procedure OutOfMemoryError;
procedure ListIndexError(aIndex,aMax: Integer; aObj: TObject);
Type
TBeepHandler = Procedure;

View File

@ -644,6 +644,20 @@ begin
Raise OutOfMemory;
end;
procedure ListIndexError(aIndex,aMax: Integer; aObj: TObject);
var
aClassName : string;
begin
if Assigned(aObj) then
aClassName:=aObj.ClassName
else
aClassName:='<nil>';
Raise EListError.CreateFmt(SErrListIndexExt,[aIndex,aClassName,aMax])
end;
{ ---------------------------------------------------------------------
Initialization/Finalization/exit code
---------------------------------------------------------------------}
@ -1211,3 +1225,5 @@ class function TOSVersion.ToString: string; static;
begin
Result:=FFull;
end;