1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, Error)]
10pub enum Error {
11 #[error("TOML parse error: {0}")]
13 TomlParse(#[from] toml::de::Error),
14
15 #[error("TOML serialize error: {0}")]
17 TomlSerialize(String),
18
19 #[error("IO error: {0}")]
21 Io(#[from] std::io::Error),
22
23 #[error("model not found: {0}")]
25 ModelNotFound(String),
26
27 #[error("deck not found: {0}")]
29 DeckNotFound(String),
30
31 #[error("field '{field}' not found in model '{model}'")]
33 FieldNotFound {
34 model: String,
36 field: String,
38 },
39
40 #[error("missing required field '{field}' in model '{model}'")]
42 MissingRequiredField {
43 model: String,
45 field: String,
47 },
48
49 #[error("media file not found: {0}")]
51 MediaNotFound(String),
52
53 #[error("invalid deck definition: {0}")]
55 InvalidDefinition(String),
56
57 #[cfg(feature = "apkg")]
59 #[error("SQLite error: {0}")]
60 Sqlite(#[from] rusqlite::Error),
61
62 #[cfg(feature = "apkg")]
64 #[error("ZIP error: {0}")]
65 Zip(#[from] zip::result::ZipError),
66
67 #[cfg(feature = "connect")]
69 #[error("AnkiConnect error: {0}")]
70 AnkiConnect(#[from] ankit::Error),
71
72 #[cfg(feature = "connect")]
74 #[error("sync conflict: {0}")]
75 SyncConflict(String),
76}