zinq_schema/error/
basic.rs1#[derive(Debug, Clone)]
2#[cfg_attr(
3 feature = "serde",
4 derive(serde::Serialize, serde::Deserialize),
5 serde(transparent)
6)]
7pub struct BasicError(String);
8
9impl BasicError {
10 pub fn new(message: &str) -> Self {
11 return Self(message.to_string());
12 }
13
14 pub fn len(&self) -> usize {
15 return self.0.len();
16 }
17}
18impl std::fmt::Display for BasicError {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 return write!(f, "{}", self.0);
21 }
22}
23
24impl std::error::Error for BasicError {
25 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
26 return Some(self);
27 }
28}