pub enum DbError {
Io(Error),
Serialization(Error),
LockPoisoned,
WriteError,
InvalidQuery(String),
TypeMismatch(String),
CollectionNotFound,
}Expand description
All possible errors that can occur in the database engine.
Using an enum instead of a string means callers can pattern-match on the error type and handle each case differently if needed.
Variants§
Io(Error)
A file system I/O error (e.g. disk full, permission denied). Wraps std::io::Error so the original OS error is preserved.
Serialization(Error)
A JSON serialization or deserialization error. Wraps serde_json::Error so the original parse error is preserved.
LockPoisoned
A Mutex was poisoned — this happens when a thread panicked while holding the lock. The lock is now in an undefined state and cannot be safely acquired. This is a programming error, not a user error.
WriteError
A generic write failure used when the specific cause is not an I/O error — for example, when the MPSC channel is closed (server shutting down) or when an OPFS browser API call fails (returns a JS error).
InvalidQuery(String)
An invalid query operator or structure was encountered.
TypeMismatch(String)
A query attempted an operation on an incompatible data type (e.g. $gt on a string that isn’t a number).
CollectionNotFound
The requested collection does not exist.
Trait Implementations§
Source§impl Display for DbError
Implement Display so DbError can be printed with {} formatting.
This is also required by the std::error::Error trait.
impl Display for DbError
Implement Display so DbError can be printed with {} formatting.
This is also required by the std::error::Error trait.