mozilla / rkv

A simple, humane, typed key-value storage solution.
https://crates.io/crates/rkv
Apache License 2.0
307 stars 52 forks source link

Error ergonomics #181

Closed victorporof closed 4 years ago

victorporof commented 4 years ago

When updating kvstore to use RKV in safe mode bug 1597898, I noticed that more LMDB-related errors were used at the top-level.

Ideally, common backend errors should be exposed as top-level store errors. This allows consumers not have to worry about which backend they're using when handling various errors in general.

For example, In case of CRLite, this was just KeyValuePairNotFound. It's better to have this a top-level store error, because otherwise consumers would have to guard for both the LMDB and SafeMode variants of this error. And if they switch to a third backend in the future, they'd have to remember to add a third guard everywhere. A similar story is in case of kvstore.

Obviously, we shouldn't do this for clearly backend-specific errors which won't be shared across potential future backends.