appstruct_ir/validation/
error.rs1use std::error::Error;
2use std::fmt;
3
4#[derive(Clone, Debug, PartialEq, Eq)]
5pub struct IrValidationError {
6 pub path: String,
7 pub message: String,
8}
9
10impl fmt::Display for IrValidationError {
11 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
12 write!(formatter, "{}: {}", self.path, self.message)
13 }
14}
15
16#[derive(Clone, Debug, PartialEq, Eq)]
17pub struct IrValidationErrors(pub(super) Vec<IrValidationError>);
18
19impl IrValidationErrors {
20 #[must_use]
21 pub fn errors(&self) -> &[IrValidationError] {
22 &self.0
23 }
24}
25
26impl fmt::Display for IrValidationErrors {
27 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
28 write!(
29 formatter,
30 "invalid AppStruct IR: {}",
31 self.0
32 .iter()
33 .map(ToString::to_string)
34 .collect::<Vec<_>>()
35 .join("; ")
36 )
37 }
38}
39
40impl Error for IrValidationErrors {}