* More routines need to display missing key name

This commit is contained in:
Michaël Van Canneyt 2024-05-15 08:21:32 +02:00
parent 4a4eadc60e
commit fc29d5ca7d
3 changed files with 18 additions and 4 deletions

View File

@ -3506,7 +3506,7 @@ begin
if not Assigned(LNode) then if not Assigned(LNode) then
begin begin
K:=aKey; K:=aKey;
TValue.Make(@K,TypeInfo(TKey),D); {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}Rtti.TValue.Make(@K,TypeInfo(TKey),D);
raise EAVLTree.CreateFmt(SDictionaryKeyNNNDoesNotExist,[D.ToString]); raise EAVLTree.CreateFmt(SDictionaryKeyNNNDoesNotExist,[D.ToString]);
end; end;
result := LNode.Value; result := LNode.Value;

View File

@ -31,7 +31,7 @@ resourcestring
SCollectionInconsistency = 'Collection inconsistency'; SCollectionInconsistency = 'Collection inconsistency';
SCollectionDuplicate = 'Collection does not allow duplicates'; SCollectionDuplicate = 'Collection does not allow duplicates';
SDictionaryKeyDoesNotExist = 'Dictionary key does not exist'; SDictionaryKeyDoesNotExist = 'Dictionary key does not exist';
SDictionaryKeyNNNDoesNotExist = 'Dictionary key %s does not exist'; SDictionaryKeyNNNDoesNotExist = 'Dictionary key "%s" does not exist';
SItemNotFound = 'Item not found'; SItemNotFound = 'Item not found';
implementation implementation

View File

@ -571,10 +571,17 @@ end;
function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.GetItem(const AKey: TKey): TValue; function TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.GetItem(const AKey: TKey): TValue;
var var
LIndex: SizeInt; LIndex: SizeInt;
D : {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}Rtti.TValue;
K : TKey;
begin begin
LIndex := FindBucketIndex(AKey); LIndex := FindBucketIndex(AKey);
if LIndex < 0 then if LIndex < 0 then
raise EListError.CreateRes(@SDictionaryKeyDoesNotExist); begin
K:=aKey;
{$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}Rtti.TValue.Make(@K,TypeInfo(TKey),D);
raise EListError.CreateFmt(SDictionaryKeyNNNDoesNotExist,[D.ToString]);
end;
Result := FItems[LIndex].Pair.Value; Result := FItems[LIndex].Pair.Value;
end; end;
@ -1993,6 +2000,9 @@ var
LHashListOrIndex: PUint32; LHashListOrIndex: PUint32;
LLookupResult: SizeInt; LLookupResult: SizeInt;
LIndex: UInt32; LIndex: UInt32;
D : {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}Rtti.TValue;
K : TKey;
begin begin
LHashListOrIndex := @LHashList[0]; LHashListOrIndex := @LHashList[0];
LLookupResult := Lookup(AKey, LHashListOrIndex); LLookupResult := Lookup(AKey, LHashListOrIndex);
@ -2001,7 +2011,11 @@ begin
LR_QUEUE: LR_QUEUE:
Result := FQueue.FItems[PtrInt(LHashListOrIndex)].Pair.Value.Pair.Value; Result := FQueue.FItems[PtrInt(LHashListOrIndex)].Pair.Value.Pair.Value;
LR_NIL: LR_NIL:
raise EListError.CreateRes(@SDictionaryKeyDoesNotExist); begin
K:=aKey;
{$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}Rtti.TValue.Make(@K,TypeInfo(TKey),D);
raise EListError.CreateFmt(SDictionaryKeyNNNDoesNotExist,[D.ToString]);
end;
else else
LIndex := LHashListOrIndex[LLookupResult + 1] and (Length(FItems[0]) - 1); LIndex := LHashListOrIndex[LLookupResult + 1] and (Length(FItems[0]) - 1);
Result := FItems[LLookupResult][LIndex].Pair.Value; Result := FItems[LLookupResult][LIndex].Pair.Value;