Skip to main content

oxilean_runtime/eval_error/
evalerror_traits.rs

1//! # EvalError - Trait Implementations
2//!
3//! This module contains trait implementations for `EvalError`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Display`
8//! - `Error`
9//!
10//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
11
12use super::types::EvalError;
13use std::fmt;
14
15impl fmt::Display for EvalError {
16    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17        write!(f, "error: {}", self.kind)?;
18        if let Some(span) = &self.span {
19            write!(f, "\n  --> {}", span)?;
20        }
21        if !self.frames.is_empty() {
22            write!(f, "\ncall stack (innermost first):")?;
23            for frame in &self.frames {
24                write!(f, "\n{}", frame)?;
25            }
26        }
27        if let Some(note) = &self.note {
28            write!(f, "\nnote: {}", note)?;
29        }
30        for hint in &self.hints {
31            write!(f, "\nhint: {}", hint)?;
32        }
33        Ok(())
34    }
35}
36
37impl std::error::Error for EvalError {}