baichun_framework_core/
macros.rs1#[macro_export]
3macro_rules! error {
4 ($kind:ident, $msg:expr) => {
5 $crate::error::Error::$kind($msg.to_string())
6 };
7}
8
9#[macro_export]
11macro_rules! ensure {
12 ($cond:expr, $kind:ident, $msg:expr) => {
13 if !$cond {
14 return Err($crate::error!($kind, $msg));
15 }
16 };
17}
18
19#[macro_export]
21macro_rules! business_err {
22 ($msg:expr) => {
23 $crate::error!(Business, $msg)
24 };
25}
26
27#[macro_export]
29macro_rules! system_err {
30 ($msg:expr) => {
31 $crate::error!(System, $msg)
32 };
33}
34
35#[macro_export]
37macro_rules! validation_err {
38 ($msg:expr) => {
39 $crate::error!(Validation, $msg)
40 };
41}
42
43#[macro_export]
45macro_rules! auth_err {
46 ($msg:expr) => {
47 $crate::error!(Authentication, $msg)
48 };
49}
50
51#[macro_export]
53macro_rules! authz_err {
54 ($msg:expr) => {
55 $crate::error!(Authorization, $msg)
56 };
57}
58
59#[macro_export]
61macro_rules! unknown_err {
62 ($msg:expr) => {
63 $crate::error!(Unknown, $msg)
64 };
65}