wx_core/errors/
mod.rs

1use std::{
2    error::Error,
3    fmt::{Debug, Display, Formatter},
4    path::PathBuf,
5};
6
7mod convert;
8mod display;
9
10/// The result type of this crate.
11pub type WxResult<T> = Result<T, WxError>;
12
13/// A boxed error kind, wrapping an [WxErrorKind].
14pub struct WxError {
15    kind: Box<WxErrorKind>,
16}
17
18/// The kind of [WxError].
19#[derive(Debug)]
20pub enum WxErrorKind {
21    /// Windows 系统错误
22    #[cfg(windows)]
23    Window {
24        /// 错误对象
25        error: windows::core::Error,
26    },
27    /// 不支持使用偏移量
28    UnsupportedOffset {
29        /// 当前版本
30        version: String,
31        /// 无法读取的字段
32        field: String,
33    },
34    /// 解密失败的 key
35    InvalidKey {
36        /// 秘钥
37        key: [u8; 32],
38        /// 待解密的文件夹
39        path: PathBuf,
40    },
41    /// 数据库错误
42    DatabaseError {
43        /// 数据库错误
44        error: sqlx::Error,
45    },
46    /// 解码失败
47    DecodeError {
48        /// 解码算法
49        algorithm: &'static str,
50        /// 错误消息
51        message: String,
52    },
53    /// 自定义报错
54    Custom {
55        /// 报错信息
56        message: String,
57    },
58}