1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum OpenCCError {
5 #[error("I/O error: {0}")]
7 Io(#[from] std::io::Error),
8
9 #[error("JSON parsing error: {0}")]
11 Json(#[from] serde_json::Error),
12
13 #[error("FST error: {0}")]
15 Fst(#[from] fst::Error),
16
17 #[error("Invalid rkyv dictionary format: {0}")]
19 InvalidDictFormat(#[from] rkyv::rancor::Error),
20
21 #[error("Invalid configuration format: {0}")]
23 InvalidConfig(String),
24
25 #[error("Configuration or resource not found in embedded data: {0}")]
27 ConfigNotFound(String),
28
29 #[error("File not found: {0}")]
31 FileNotFound(String),
32
33 #[error("Unsupported dictionary type: {0}")]
35 UnsupportedDictType(String),
36
37 #[error("Dictionary compile failed")]
39 DictCompileError(#[from] anyhow::Error),
40}
41
42pub type Result<T> = std::result::Result<T, OpenCCError>;