use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum JoydbError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("{0} is not a file")]
NotFile(PathBuf),
#[error("{0} is not a directory")]
NotDirectory(PathBuf),
#[error("Serialize error: {0}")]
Serialize(Box<dyn std::error::Error + Send + Sync>),
#[error("Deserialize error: {0}")]
Deserialize(Box<dyn std::error::Error + Send + Sync>),
#[error("{model} with id = {id} already exists")]
DuplicatedId {
id: String,
model: String,
},
#[error("{model} with id = {id} not found")]
NotFound {
id: String,
model: String,
},
#[error("Custom error: {0}")]
Custom(Box<dyn std::error::Error + Send + Sync>),
}