vos_error/for_3rd/
mod.rs

1use std::fmt::Display;
2
3#[cfg(feature = "bigdecimal")]
4pub use bigdecimal::BigDecimal;
5use diagnostic::{DiagnosticError, DiagnosticLevel};
6#[cfg(feature = "email_address")]
7pub use email_address::EmailAddress;
8#[cfg(feature = "num")]
9pub use num::{BigInt, Zero};
10#[cfg(feature = "url")]
11pub use url::Url;
12
13#[cfg(feature = "semver")]
14pub use semver::Version;
15
16#[cfg(feature = "serde_json")]
17pub use serde_json::Value as Json;
18
19use crate::{VosError, VosErrorKind};
20
21#[cfg(feature = "bigdecimal")]
22mod for_big_decimal;
23#[cfg(feature = "num")]
24mod for_num;
25#[cfg(feature = "peginator")]
26mod for_peg;
27#[cfg(feature = "semver")]
28mod for_semver;
29#[cfg(feature = "email_address")]
30mod for_email;
31
32impl From<DiagnosticError> for VosError {
33    fn from(error: DiagnosticError) -> Self {
34        Self::runtime_error(error.to_string())
35    }
36}
37
38impl VosError {
39    pub fn runtime_error<S>(msg: S) -> Self
40    where
41        S: Display,
42    {
43        Self {
44            kind: Box::new(VosErrorKind::RuntimeError(msg.to_string())),
45            level: DiagnosticLevel::Error,
46            file: Default::default(),
47        }
48    }
49}