mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 14:27:59 +02:00
* When raising error, display missing key value as string, if possible
This commit is contained in:
parent
291532e740
commit
259af2d252
@ -46,11 +46,11 @@ interface
|
||||
{$IFDEF FPC_DOTTEDUNITS}
|
||||
uses
|
||||
System.RtlConsts, System.Classes, System.SysUtils, System.Generics.MemoryExpanders, System.Generics.Defaults,
|
||||
System.Generics.Helpers, System.Generics.Strings, System.Types;
|
||||
System.Generics.Helpers, System.Generics.Strings, System.Types, System.Rtti;
|
||||
{$ELSE FPC_DOTTEDUNITS}
|
||||
uses
|
||||
RtlConsts, Classes, SysUtils, Generics.MemoryExpanders, Generics.Defaults,
|
||||
Generics.Helpers, Generics.Strings, Types;
|
||||
Generics.Helpers, Generics.Strings, Types, Rtti;
|
||||
{$ENDIF FPC_DOTTEDUNITS}
|
||||
|
||||
{.$define EXTRA_WARNINGS}
|
||||
@ -3492,13 +3492,23 @@ begin
|
||||
Result := TValueCollection(FValues);
|
||||
end;
|
||||
|
||||
|
||||
function TCustomAVLTreeMap<TREE_CONSTRAINTS>.GetItem(const AKey: TKey): TValue;
|
||||
|
||||
var
|
||||
LNode: PNode;
|
||||
// Need to differentiate with TValue template type...
|
||||
D : {$IFDEF FPC_DOTTEDUNITS}System.{$ENDIF}Rtti.TValue;
|
||||
K : TKey;
|
||||
|
||||
begin
|
||||
LNode := Find(AKey);
|
||||
if not Assigned(LNode) then
|
||||
raise EAVLTree.CreateRes(@SDictionaryKeyDoesNotExist);
|
||||
begin
|
||||
K:=aKey;
|
||||
TValue.Make(@K,TypeInfo(TKey),D);
|
||||
raise EAVLTree.CreateFmt(SDictionaryKeyNNNDoesNotExist,[D.ToString]);
|
||||
end;
|
||||
result := LNode.Value;
|
||||
end;
|
||||
|
||||
|
@ -31,6 +31,7 @@ resourcestring
|
||||
SCollectionInconsistency = 'Collection inconsistency';
|
||||
SCollectionDuplicate = 'Collection does not allow duplicates';
|
||||
SDictionaryKeyDoesNotExist = 'Dictionary key does not exist';
|
||||
SDictionaryKeyNNNDoesNotExist = 'Dictionary key %s does not exist';
|
||||
SItemNotFound = 'Item not found';
|
||||
|
||||
implementation
|
||||
|
Loading…
Reference in New Issue
Block a user