use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("TOML parse error: {0}")]
TomlParse(#[from] toml::de::Error),
#[error("TOML serialize error: {0}")]
TomlSerialize(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("model not found: {0}")]
ModelNotFound(String),
#[error("deck not found: {0}")]
DeckNotFound(String),
#[error("field '{field}' not found in model '{model}'")]
FieldNotFound {
model: String,
field: String,
},
#[error("missing required field '{field}' in model '{model}'")]
MissingRequiredField {
model: String,
field: String,
},
#[error("media file not found: {0}")]
MediaNotFound(String),
#[error("invalid deck definition: {0}")]
InvalidDefinition(String),
#[cfg(feature = "apkg")]
#[error("SQLite error: {0}")]
Sqlite(#[from] rusqlite::Error),
#[cfg(feature = "apkg")]
#[error("ZIP error: {0}")]
Zip(#[from] zip::result::ZipError),
#[cfg(feature = "connect")]
#[error("AnkiConnect error: {0}")]
AnkiConnect(#[from] ankit::Error),
#[cfg(feature = "connect")]
#[error("sync conflict: {0}")]
SyncConflict(String),
}