use crate::manifest::ResourceIdentifier;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum MrBundleError {
#[error("{0}: {1}")]
IoError(String, std::io::Error),
#[error("Manifest references resources that were not provided when attempting to create a bundle: {0:?}")]
MissingResources(Vec<ResourceIdentifier>),
#[error("Resources were provided when attempting to create a bundle that were not referenced in the manifest: {0:?}")]
UnusedResources(Vec<ResourceIdentifier>),
#[error(transparent)]
MsgpackEncodeError(#[from] rmp_serde::encode::Error),
#[error("Failed to decode bundle to [{0}] due to a deserialization error: {1}")]
MsgpackDecodeError(String, rmp_serde::decode::Error),
#[cfg(feature = "fs")]
#[cfg_attr(docsrs, doc(cfg(feature = "fs")))]
#[error(transparent)]
YamlError(#[from] serde_yaml::Error),
#[cfg(feature = "fs")]
#[cfg_attr(docsrs, doc(cfg(feature = "fs")))]
#[error("The supplied path '{0}' has no parent directory.")]
ParentlessPath(std::path::PathBuf),
#[cfg(feature = "fs")]
#[cfg_attr(docsrs, doc(cfg(feature = "fs")))]
#[error("The target directory '{0}' already exists.")]
DirectoryExists(std::path::PathBuf),
}
pub type MrBundleResult<T> = Result<T, MrBundleError>;