Every failure raises a subclass of ustore.Error, itself a RuntimeError, and each carries the status the C ABI reported as its status attribute, a ustore.Status member:
transaction = database.transaction(ustore.Watch.KEYS)try: transaction.set(key, value) transaction.commit(ustore.Durability.FLUSHED)except ustore.ConflictError as error: assert error.status in (ustore.Status.WRITE_CONFLICT, ustore.Status.READ_CONFLICT)finally: transaction.close()
SUCCESS and DEFERRED raise nothing, and every other member has its own class, which also derives the built-in naming the same fault where one exists:
OUT_OF_MEMORY → OutOfMemoryError, a MemoryError
READ_ONLY → ReadOnlyError
IO → InputOutputError, an OSError
DEVICE → DeviceError
MALFORMED → MalformedError, a ValueError
INTERNAL → InternalError
UNINITIALIZED → UninitializedError
CONTENDED → ContendedError
CANCELLED → CancelledError
UNSUPPORTED → UnsupportedError, a NotImplementedError
INVALID_ARGUMENT → InvalidArgumentError, a ValueError
NOT_FOUND → NotFoundError, a KeyError
ALREADY_EXISTS → AlreadyExistsError, a ValueError
WRITE_CONFLICT → WriteConflictError, a ConflictError
READ_CONFLICT → ReadConflictError, a ConflictError
PHANTOM_CONFLICT → PhantomConflictError, a ConflictError
CAPACITY_EXHAUSTED → CapacityExhaustedError, an OverflowError
So except KeyError catches a missing collection, and except ConflictError is the one clause a retry loop needs for the three conflicts.
A database view_rocksdb opened raises ReadOnlyError from every call that would change it: writes, removes, transactions, collection creates and drops, clears and compactions.
A failure the binding catches before the boundary raises the class the engine would have raised for the same fault: a closed database, transaction, snapshot or executor raises UninitializedError, a view of a collection holding another modality raises InvalidArgumentError, and a count of values that disagrees with the count of keys raises InvalidArgumentError too.
An argument of the wrong Python type raises TypeError, and a snapshot refuses a write with one.
ContendedErrorThe call was refused rather than waited for: a full deferred table, an arena serving another call or exporting a buffer, or a transaction serving another call; retry it once that one finishes or the buffer is released.