use std::fmt;
use super::DeclarationError;
#[derive(Debug)]
pub struct MountError {
panel: String,
errors: Vec<DeclarationError>,
}
impl MountError {
pub(crate) fn new(panel: &str, errors: Vec<DeclarationError>) -> Self {
Self {
panel: panel.to_string(),
errors,
}
}
pub fn panel(&self) -> &str {
&self.panel
}
pub fn errors(&self) -> &[DeclarationError] {
&self.errors
}
}
impl fmt::Display for MountError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "panel '{}' cannot mount:", self.panel)?;
for error in &self.errors {
write!(f, "\n - {error}")?;
}
Ok(())
}
}
impl std::error::Error for MountError {}