1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::fmt::Display;

use diagnostic::{DiagnosticError, DiagnosticLevel};

use crate::{VosError, VosErrorKind};

#[cfg(feature = "bigdecimal")]
mod for_big_decimal;
#[cfg(feature = "num")]
mod for_num;
#[cfg(feature = "peginator")]
mod for_peg;

impl From<DiagnosticError> for VosError {
    fn from(error: DiagnosticError) -> Self {
        Self::runtime_error(error.to_string())
    }
}

impl VosError {
    pub fn runtime_error<S>(msg: S) -> Self
    where
        S: Display,
    {
        Self {
            kind: Box::new(VosErrorKind::RuntimeError(msg.to_string())),
            level: DiagnosticLevel::Error,
            file: Default::default(),
        }
    }
}