#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Invalid plugin: {0}")]
InvalidPlugin(String),
#[error("Invalid manifest: {0}")]
InvalidManifest(String),
#[error("Invalid UI schema: {0}")]
InvalidSchema(String),
#[error("Validation error: {0}")]
Validation(String),
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
}
impl Error {
#[must_use]
pub fn plugin<S: Into<String>>(msg: S) -> Self {
Self::InvalidPlugin(msg.into())
}
#[must_use]
pub fn manifest<S: Into<String>>(msg: S) -> Self {
Self::InvalidManifest(msg.into())
}
#[must_use]
pub fn schema<S: Into<String>>(msg: S) -> Self {
Self::InvalidSchema(msg.into())
}
#[must_use]
pub fn validation<S: Into<String>>(msg: S) -> Self {
Self::Validation(msg.into())
}
}
pub type Result<T> = std::result::Result<T, Error>;