From 97412f04d29eeef83d1cb92cda0d641d31c1be94 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Fri, 16 Aug 2024 20:06:21 -0400 Subject: [PATCH] Improve "key not found" error messages for string/symbol keys We don't know how to represent arbitrary objects as strings at this low level, but this takes care of two very common cases. --- M2/Macaulay2/d/hashtables.dd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/M2/Macaulay2/d/hashtables.dd b/M2/Macaulay2/d/hashtables.dd index 25b7ac55f0..104132acd6 100644 --- a/M2/Macaulay2/d/hashtables.dd +++ b/M2/Macaulay2/d/hashtables.dd @@ -340,7 +340,12 @@ export lookup1force(object:HashTable,key:Expr,keyhash:hash_t):Expr := ( bucket = bucket.next; ); if lockit then unlock(object.mutex); - buildErrorPacket("key not found in hash table")); + msg := "key not found in hash table"; + when key + is x:stringCell do msg = msg + ": \"" + x.v + "\"" + is x:SymbolClosure do msg = msg + ": " + x.symbol.word.name + else nothing; + buildErrorPacket(msg)); export lookup1force(object:HashTable,key:Expr):Expr := lookup1force(object,key,hash(key)); export lookup1Q(object:HashTable,key:Expr,keyhash:hash_t):bool := ( lockit := object.Mutable && !object.beingInitialized;