1use anyhow::Result;
2
3pub type StateResult<T> = Result<T>;
5
6#[allow(clippy::module_inception)]
8pub mod error {
9 use anyhow::anyhow;
10
11 pub fn plugin_init_error(msg: impl Into<String>) -> anyhow::Error {
13 anyhow!("插件状态初始化失败: {}", msg.into())
14 }
15
16 pub fn plugin_apply_error(msg: impl Into<String>) -> anyhow::Error {
18 anyhow!("插件状态应用失败: {}", msg.into())
19 }
20
21 pub fn transaction_error(msg: impl Into<String>) -> anyhow::Error {
23 anyhow!("事务应用失败: {}", msg.into())
24 }
25
26 pub fn configuration_error(msg: impl Into<String>) -> anyhow::Error {
28 anyhow!("配置错误: {}", msg.into())
29 }
30
31 pub fn field_error(msg: impl Into<String>) -> anyhow::Error {
33 anyhow!("字段操作失败: {}", msg.into())
34 }
35
36 pub fn schema_error(msg: impl Into<String>) -> anyhow::Error {
38 anyhow!("Schema错误: {}", msg.into())
39 }
40
41 pub fn plugin_not_found(msg: impl Into<String>) -> anyhow::Error {
43 anyhow!("插件未找到: {}", msg.into())
44 }
45
46 pub fn invalid_plugin_state(msg: impl Into<String>) -> anyhow::Error {
48 anyhow!("插件状态无效: {}", msg.into())
49 }
50
51 pub fn serialize_error(msg: impl Into<String>) -> anyhow::Error {
53 anyhow!("序列化失败: {}", msg.into())
54 }
55
56 pub fn deserialize_error(msg: impl Into<String>) -> anyhow::Error {
58 anyhow!("反序列化失败: {}", msg.into())
59 }
60}