use thiserror::Error; pub type Result = std::result::Result; #[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) -> Self { Self::Corrupt(message.into()) } } impl From for std::io::Error { fn from(error: StorageError) -> Self { std::io::Error::other(error.to_string()) } }