1use anyhow::Result;
2
3pub type StateResult<T> = Result<T>;
5
6pub mod error {
8 use anyhow::anyhow;
9
10 pub fn plugin_init_error(msg: impl Into<String>) -> anyhow::Error {
12 anyhow!("插件状态初始化失败: {}", msg.into())
13 }
14
15 pub fn plugin_apply_error(msg: impl Into<String>) -> anyhow::Error {
17 anyhow!("插件状态应用失败: {}", msg.into())
18 }
19
20 pub fn transaction_error(msg: impl Into<String>) -> anyhow::Error {
22 anyhow!("事务应用失败: {}", msg.into())
23 }
24
25 pub fn configuration_error(msg: impl Into<String>) -> anyhow::Error {
27 anyhow!("配置错误: {}", msg.into())
28 }
29
30 pub fn field_error(msg: impl Into<String>) -> anyhow::Error {
32 anyhow!("字段操作失败: {}", msg.into())
33 }
34
35 pub fn schema_error(msg: impl Into<String>) -> anyhow::Error {
37 anyhow!("Schema错误: {}", msg.into())
38 }
39
40 pub fn plugin_not_found(msg: impl Into<String>) -> anyhow::Error {
42 anyhow!("插件未找到: {}", msg.into())
43 }
44
45 pub fn invalid_plugin_state(msg: impl Into<String>) -> anyhow::Error {
47 anyhow!("插件状态无效: {}", msg.into())
48 }
49
50 pub fn serialize_error(msg: impl Into<String>) -> anyhow::Error {
52 anyhow!("序列化失败: {}", msg.into())
53 }
54
55 pub fn deserialize_error(msg: impl Into<String>) -> anyhow::Error {
57 anyhow!("反序列化失败: {}", msg.into())
58 }
59}