scsys_xtask/
error.rs

1/*
2    Appellation: error <module>
3    Contrib: @FL03
4*/
5
6/// a type alias for a [`Result`] type with a default error type of [`Error`]
7#[allow(dead_code)]
8pub(crate) type Result<T = ()> = core::result::Result<T, Error>;
9
10#[derive(Debug, thiserror::Error)]
11pub enum Error {
12    #[error("Build Failed: {0}")]
13    BuildFailed(String),
14    #[error("Invalid output: {0}")]
15    InvalidOutput(String),
16
17    #[error(transparent)]
18    AnyError(#[from] anyhow::Error),
19    #[error(transparent)]
20    BoxError(#[from] Box<dyn core::error::Error + Send + Sync + 'static>),
21    #[error(transparent)]
22    IoError(#[from] std::io::Error),
23    #[cfg(feature = "json")]
24    #[error(transparent)]
25    JsonError(#[from] serde_json::Error),
26    #[error("[Unknown Error] {0}")]
27    UnknownError(String),
28}
29
30impl From<String> for Error {
31    fn from(err: String) -> Self {
32        Error::UnknownError(err)
33    }
34}
35
36impl From<&str> for Error {
37    fn from(err: &str) -> Self {
38        Error::UnknownError(err.to_string())
39    }
40}