use std::path::PathBuf;
use crate::plugins::TRUST_PROJECT_PLUGINS_ENV;
#[derive(Debug, thiserror::Error)]
pub(crate) enum ManageError {
#[error("{0}")]
NotFound(String),
#[error(
"plugin already exists at {} (pass --force to replace)",
crate::paths::display(.path)
)]
Exists { name: String, path: PathBuf },
#[error(
"`{name}` is a project plugin and the workspace is not trusted; set {TRUST_PROJECT_PLUGINS_ENV}=1 to update it"
)]
Untrusted { name: String },
#[error("{0}")]
InvalidPackage(String),
#[error("{0}")]
Fetch(String),
#[error("{0}")]
Refused(String),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Other(#[from] anyhow::Error),
}
impl ManageError {
pub(crate) fn invalid_package(error: &anyhow::Error) -> Self {
Self::InvalidPackage(format!("{error:#}"))
}
pub(crate) fn fetch(error: &anyhow::Error) -> Self {
Self::Fetch(format!("{error:#}"))
}
}