use std::borrow::Cow;

#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
    /// TOML parsing error
    #[error(transparent)]
    InvalidToml {
        #[from]
        inner: toml_edit::TomlError,
    },

    /// Cargo.toml manifest parsing error
    #[error("Invalid Cargo.toml manifest: {}", .message)]
    InvalidManifest { message: Cow<'static, str> },
}

impl Error {
    pub(crate) fn manifest<M>(message: M) -> Self
    where
        M: Into<Cow<'static, str>>,
    {
        Error::InvalidManifest {
            message: message.into(),
        }
    }
}
