use std::io;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum GspError {
#[error("dimension mismatch: {0}")]
Dimensions(String),
#[error("index out of bounds: {0}")]
Index(String),
#[error("invalid kernel: {0}")]
InvalidKernel(String),
#[error("invalid scale(s): {0}")]
InvalidScales(String),
#[error("factorization failure: {0}")]
Factorization(String),
#[error("singular solve: {0}")]
SingularSolve(String),
#[error("parse/decode failure: {0}")]
Parse(String),
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("cache error: {0}")]
Cache(String),
#[error("resource not found: {0}")]
ResourceNotFound(String),
#[error("unsupported data format: {0}")]
UnsupportedFormat(String),
}
impl From<serde_json::Error> for GspError {
fn from(value: serde_json::Error) -> Self {
Self::Parse(value.to_string())
}
}
impl From<matrw::MatrwError> for GspError {
fn from(value: matrw::MatrwError) -> Self {
Self::Parse(value.to_string())
}
}
impl From<sprs::errors::LinalgError> for GspError {
fn from(value: sprs::errors::LinalgError) -> Self {
Self::Factorization(value.to_string())
}
}