scsys_config/
error.rs

1/*
2    Appellation: error <module>
3    Contrib: FL03 <jo3mccain@icloud.com>
4*/
5//! the custom error types and routines for the config crate.
6
7/// a type alias for a [`Result`] type equipped with a custom [`Error`] type
8pub type Result<T = ()> = core::result::Result<T, Error>;
9
10/// The [`Error`] type enumerates the handled errors within the configuration crate
11#[derive(Debug, thiserror::Error)]
12pub enum Error {
13    #[error(transparent)]
14    CoreError(scsys_core::error::Error),
15    #[error("Configuration error: {0}")]
16    ParseError(String),
17    #[cfg(feature = "config")]
18    #[error(transparent)]
19    ConfigError(#[from] config::ConfigError),
20    #[cfg(feature = "url")]
21    #[error(transparent)]
22    UrlError(#[from] url::ParseError),
23}
24
25impl From<Error> for scsys_core::error::Error {
26    fn from(err: Error) -> Self {
27        match err {
28            Error::CoreError(e) => e,
29            e => scsys_core::error::Error::box_error(e),
30        }
31    }
32}