pub enum DbError {
Io(Error),
Serialization(Error),
LockPoisoned,
WriteError,
InvalidQuery(String),
TypeMismatch(String),
CollectionNotFound,
Conflict,
SchemaValidationError(String),
}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.
Conflict
An optimistic concurrency control (OCC) conflict occurred. The document version provided by the client is outdated.
SchemaValidationError(String)
A document failed JSON schema validation.
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.
Source§impl Error for DbError
Allow std::io::Error to be converted to DbError with the ? operator.
This means any function returning Result<_, DbError> can use ? on
file I/O operations without manually wrapping the error.
impl Error for DbError
Allow std::io::Error to be converted to DbError with the ? operator.
This means any function returning Result<_, DbError> can use ? on
file I/O operations without manually wrapping the error.
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()