1use derive_more::From;
2use orion_error::{OrionError, StructError, UnifiedReason};
3use serde::Serialize;
4
5#[derive(Debug, Clone, PartialEq, Serialize, From, OrionError)]
6pub enum KnowReason {
7 #[orion_error(identity = "biz.not_data")]
8 NotData,
9 #[orion_error(transparent)]
10 General(UnifiedReason),
11}
12
13impl KnowReason {
14 pub fn from_conf() -> Self {
15 Self::core_conf()
16 }
17
18 pub fn from_logic() -> Self {
19 Self::logic_error()
20 }
21
22 pub fn from_res() -> Self {
23 Self::system_error()
24 }
25
26 pub fn from_rule() -> Self {
27 Self::rule_error()
28 }
29}
30
31impl std::error::Error for KnowReason {}
32
33pub type KnowledgeError = StructError<KnowReason>;
34pub type KnowledgeResult<T> = Result<T, KnowledgeError>;
35
36#[deprecated(since = "0.12.2", note = "use KnowReason instead")]
37pub type Reason = KnowReason;