Path: redb/redb.Core/Exceptions/RedbDictionaryKeyException.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Exceptions/RedbDictionaryKeyException.cs
----
using System;
namespace redb.Core.Exceptions;
///
/// A load stopped because a stored dictionary key does not read as the key type of the class: most often an enum member
/// renamed or removed after the object was saved (an enum key is stored by its member name, so renumbering is harmless
/// but renaming is not). No entry is skipped: the object is not returned with an entry missing. Restore the member, or
/// rewrite the stored keys of the old name (_values._array_index of the dictionary's structure).
///
public class RedbDictionaryKeyException : Exception
{
/// The name of the dictionary property.
public string Field { get; }
/// The key as it is stored.
public string StoredKey { get; }
/// The key type the class declares.
public Type KeyType { get; }
public RedbDictionaryKeyException(string field, string storedKey, Type keyType, Exception inner)
: base($"The stored key '{storedKey}' of the dictionary '{field}' does not read as {keyType.Name}: {inner.Message} " +
"A member renamed or removed after the object was saved leaves keys of the old name; restore the member or " +
"rewrite those stored keys.", inner)
{
Field = field;
StoredKey = storedKey;
KeyType = keyType;
}
}