1use derive_more::From;
2use orion_error::{OrionError, StructError, UnifiedReason};
3use serde_derive::Serialize;
4
5#[derive(Debug, PartialEq, Serialize, From, OrionError)]
6pub enum OrionSecReason {
7 #[orion_error(transparent)]
8 Sec(SecReason),
9 #[orion_error(transparent)]
10 General(UnifiedReason),
11}
12
13#[derive(Debug, PartialEq, Serialize, OrionError)]
14pub enum SecReason {
15 #[orion_error(identity = "biz.sensitive_msg", code = 101)]
16 SensitiveMsg(String),
17 #[orion_error(identity = "biz.no_permission", code = 201)]
18 NoPermission(String),
19 #[orion_error(identity = "biz.deception", code = 301)]
20 Deception(String),
21 #[orion_error(identity = "biz.un_authenticated", code = 401)]
22 UnAuthenticated(String),
23}
24
25impl From<orion_conf::ConfIOReason> for OrionSecReason {
26 fn from(r: orion_conf::ConfIOReason) -> Self {
27 match r {
28 orion_conf::ConfIOReason::General(u) => OrionSecReason::General(u),
29 _ => OrionSecReason::General(UnifiedReason::system_error()),
30 }
31 }
32}
33
34pub type SecError = StructError<OrionSecReason>;
35pub type SecResult<T> = Result<T, SecError>;