diff --git a/table.go b/table.go index 322e950..c869814 100644 --- a/table.go +++ b/table.go @@ -173,18 +173,18 @@ func (t *Table[K, V]) Put(key K, value V) (displaced Entry[K, V], err error) { // early when the table is sparse, while the latter catches cases where // growing never helps. if t.load() < t.minLoadFactor { - return entry, fmt.Errorf("bad hash: resize on load %d/%d", t.Size(), t.TotalCapacity()) + return entry, fmt.Errorf("hash functions produced a cycle at load %d/%d: %w", t.Size(), t.TotalCapacity(), ErrBadHash) } // It is theoretically possible to have a table with a larger capacity // that is valid. But this chance is astronomically small, so we ignore // it in this implementation. if grew := t.grow(); !grew { - return entry, fmt.Errorf("bad hash: could not redistribute entries into larger table") + return entry, fmt.Errorf("could not redistribute entries into larger table: %w", ErrBadHash) } } - return entry, fmt.Errorf("bad hash: could not place entry after %d resizes", defaultGrowthLimit) + return entry, fmt.Errorf("could not place entry after %d resizes: %w", defaultGrowthLimit, ErrBadHash) } // Drop removes a value for a key in the table. Returns whether the key had