use thiserror::Error;
#[derive(Debug, Error)]
pub enum StemError {
#[error("{0}")]
Anyhow(#[from] anyhow::Error),
#[error("Registry error: {0}")]
Registry(String),
#[error("Checksum mismatch for {path}")]
Checksum { path: String },
#[error("Cache dir not available")]
CacheDirUnavailable,
#[error("manifest error: {0}")]
Manifest(String),
}
impl From<std::io::Error> for StemError {
fn from(e: std::io::Error) -> Self {
StemError::Anyhow(e.into())
}
}
impl From<serde_json::Error> for StemError {
fn from(e: serde_json::Error) -> Self {
StemError::Anyhow(e.into())
}
}
impl From<reqwest::Error> for StemError {
fn from(e: reqwest::Error) -> Self {
StemError::Anyhow(e.into())
}
}
impl From<hex::FromHexError> for StemError {
fn from(e: hex::FromHexError) -> Self {
StemError::Anyhow(e.into())
}
}
impl From<ort::Error> for StemError {
fn from(e: ort::Error) -> Self {
StemError::Anyhow(e.into())
}
}
impl From<ndarray::ShapeError> for StemError {
fn from(e: ndarray::ShapeError) -> Self {
StemError::Anyhow(e.into())
}
}
pub type Result<T> = std::result::Result<T, StemError>;