use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub enum RandomxError {
CacheAllocError,
DatasetAllocError,
VmAllocError,
}
impl fmt::Display for RandomxError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
RandomxError::CacheAllocError => write!(f, "Failed to allocate cache"),
RandomxError::DatasetAllocError => write!(f, "Failed to allocate datataset"),
RandomxError::VmAllocError => write!(f, "Failed to create VM"),
}
}
}
impl Error for RandomxError {
fn description(&self) -> &str {
match *self {
RandomxError::CacheAllocError => "Failed to allocate cache",
RandomxError::DatasetAllocError => "Failed to allocate dataset",
RandomxError::VmAllocError => "Failed to create VM",
}
}
fn cause(&self) -> Option<&dyn Error> {
None
}
}