common_error/lib.rs
1
2pub mod handle_error_macro;
3
4use std::error::Error;
5use std::fmt::{Display, Formatter};
6
7#[derive(Debug, Clone)]
8pub struct CommonError {
9 pub code: String,
10 pub message: String,
11}
12
13impl Display for CommonError {
14 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
15 write!(f, "error code [{}]:{} \n", self.code, self.message)
16 }
17}
18
19impl Error for CommonError {}