pub enum DbError {
Io(Error),
Serialization(Error),
LockPoisoned,
WriteError,
InvalidQuery(String),
TypeMismatch(String),
CollectionNotFound,
SchemaValidationError(String),
Conflict,
}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.
SchemaValidationError(String)
A document failed JSON schema validation.
Conflict
An optimistic concurrency control (OCC) conflict occurred. The document version provided by the client is outdated.
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.
Auto Trait Implementations§
impl Freeze for DbError
impl !RefUnwindSafe for DbError
impl Send for DbError
impl Sync for DbError
impl Unpin for DbError
impl UnsafeUnpin for DbError
impl !UnwindSafe for DbError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.