use std::fmt;
use crate::enums::LibXCSpin;
#[derive(Debug)]
pub enum LibXCError {
NotFound(String),
InitError { func_id: i32, spin: LibXCSpin },
ComputeError(String),
ParamSetError { param_name: String, details: String },
#[cfg(feature = "cuda")]
CudaError(String),
}
impl fmt::Display for LibXCError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LibXCError::NotFound(msg) => write!(f, "not found: {msg}"),
LibXCError::InitError { func_id, spin } => {
write!(f, "failed to initialize functional {func_id} with spin {spin:?}")
},
LibXCError::ComputeError(msg) => write!(f, "compute error: {msg}"),
LibXCError::ParamSetError { param_name, details } => {
write!(f, "parameter set error for {param_name}: {details}")
},
#[cfg(feature = "cuda")]
LibXCError::CudaError(msg) => write!(f, "cuda error: {msg}"),
}
}
}
impl std::error::Error for LibXCError {}