BREAKING CHANGE(core): replace the TypeScript database engine with a Rust-backed embedded server and bridge
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors that can occur in storage operations.
|
||||
#[derive(Debug, Error)]
|
||||
pub enum StorageError {
|
||||
#[error("not found: {0}")]
|
||||
NotFound(String),
|
||||
|
||||
#[error("already exists: {0}")]
|
||||
AlreadyExists(String),
|
||||
|
||||
#[error("I/O error: {0}")]
|
||||
IoError(#[from] std::io::Error),
|
||||
|
||||
#[error("serialization error: {0}")]
|
||||
SerializationError(String),
|
||||
|
||||
#[error("conflict detected: {0}")]
|
||||
ConflictError(String),
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for StorageError {
|
||||
fn from(e: serde_json::Error) -> Self {
|
||||
StorageError::SerializationError(e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bson::de::Error> for StorageError {
|
||||
fn from(e: bson::de::Error) -> Self {
|
||||
StorageError::SerializationError(e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bson::ser::Error> for StorageError {
|
||||
fn from(e: bson::ser::Error) -> Self {
|
||||
StorageError::SerializationError(e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
pub type StorageResult<T> = Result<T, StorageError>;
|
||||
Reference in New Issue
Block a user