use std::{error, fmt};
#[non_exhaustive]
#[derive(Debug, Clone)]
pub enum DylinkError {
FnNotFound(String),
LibNotLoaded(String),
ListNotLoaded(String),
}
impl error::Error for DylinkError {}
impl fmt::Display for DylinkError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let err = match &self {
Self::FnNotFound(fn_name) => format!("function `{fn_name}` not found"),
Self::LibNotLoaded(lib_name) => format!("library `{lib_name}` could not be loaded"),
Self::ListNotLoaded(msgs) => {
return write!(f, "Dylink Error(s):\n{msgs}");
}
};
write!(f, "Dylink Error: {err}")
}
}