1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum OpenCCError {
6 #[error("I/O error: {0}")]
8 Io(#[from] std::io::Error),
9
10 #[error("JSON parsing error: {0}")]
12 Json(#[from] serde_json::Error),
13
14 #[error("FST error: {0}")]
16 Fst(#[from] fst::Error),
17
18 #[error("Bincode decoding error: {0}")]
20 BincodeDecode(#[from] bincode::error::DecodeError),
21
22 #[error("Bincode encoding error: {0}")]
24 BincodeEncode(#[from] bincode::error::EncodeError),
25
26 #[error("Invalid configuration format: {0}")]
28 InvalidConfig(String),
29
30 #[error("Configuration or resource not found in embedded data: {0}")]
32 ConfigNotFound(String),
33
34 #[error("File not found: {0}")]
36 FileNotFound(String),
37
38 #[error("Unsupported dictionary type: {0}")]
40 UnsupportedDictType(String),
41
42 #[error("Dictionary compile failed")]
44 DictCompileError(#[from] anyhow::Error),
45}
46
47pub type Result<T> = std::result::Result<T, OpenCCError>;