zinq_schema/error/
group.rs1#[derive(Debug, Clone)]
2#[cfg_attr(
3 feature = "serde",
4 derive(serde::Serialize, serde::Deserialize),
5 serde(transparent)
6)]
7pub struct GroupError(Vec<super::Error>);
8
9impl GroupError {
10 pub fn new() -> Self {
11 return Self(vec![]);
12 }
13
14 pub fn len(&self) -> usize {
15 return self.0.len();
16 }
17
18 pub fn add(&mut self, err: super::Error) -> &mut Self {
19 self.0.push(err);
20 return self;
21 }
22}
23impl std::fmt::Display for GroupError {
24 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25 write!(f, "[")?;
26
27 for (i, error) in self.0.iter().enumerate() {
28 write!(f, "\n\t{}", error)?;
29
30 if i < self.len() - 1 {
31 write!(f, ",")?;
32 }
33 }
34
35 return write!(f, "]");
36 }
37}
38
39impl std::error::Error for GroupError {
40 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
41 return Some(self);
42 }
43}