Skip to main content

oxilean_kernel/error/
errorreport_traits.rs

1//! # ErrorReport - Trait Implementations
2//!
3//! This module contains trait implementations for `ErrorReport`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Display`
8//! - `Error`
9//! - `From`
10//!
11//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
12
13use super::types::{ErrorReport, KernelError};
14use std::fmt;
15
16impl fmt::Display for ErrorReport {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        if let Some(loc) = &self.location {
19            write!(f, "error in '{}': {}", loc, self.primary)?;
20        } else {
21            write!(f, "error: {}", self.primary)?;
22        }
23        for note in &self.notes {
24            write!(f, "\n  note: {}", note)?;
25        }
26        Ok(())
27    }
28}
29
30impl std::error::Error for ErrorReport {}
31
32impl From<KernelError> for ErrorReport {
33    fn from(err: KernelError) -> Self {
34        ErrorReport::new(err)
35    }
36}