json stores are gone, they nulled out every data ref on load and wrote the null straight back on save. shop json and the purchase commands ended up in here too.
23 lines
644 B
Rust
23 lines
644 B
Rust
use thiserror::Error;
|
|
pub type Result<T> = std::result::Result<T, StorageError>;
|
|
#[derive(Debug, Error)]
|
|
pub enum StorageError {
|
|
#[error("database: {0}")]
|
|
Database(#[from] sqlx::Error),
|
|
#[error("migration: {0}")]
|
|
Migration(#[from] sqlx::migrate::MigrateError),
|
|
#[error("io: {0}")]
|
|
Io(#[from] std::io::Error),
|
|
#[error("{0}")]
|
|
Corrupt(String),
|
|
}
|
|
impl StorageError {
|
|
pub fn corrupt(message: impl Into<String>) -> Self {
|
|
Self::Corrupt(message.into())
|
|
}
|
|
}
|
|
impl From<StorageError> for std::io::Error {
|
|
fn from(error: StorageError) -> Self {
|
|
std::io::Error::other(error.to_string())
|
|
}
|
|
}
|