randomx_bindings/
error.rs1use std::error::Error;
2use std::fmt;
3
4#[derive(Debug)]
5pub enum RandomxError {
6 CacheAllocError,
13
14 DatasetAllocError,
19
20 VmAllocError,
26}
27
28impl fmt::Display for RandomxError {
29 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
30 match *self {
31 RandomxError::CacheAllocError => write!(f, "Failed to allocate cache"),
32 RandomxError::DatasetAllocError => write!(f, "Failed to allocate datataset"),
33 RandomxError::VmAllocError => write!(f, "Failed to create VM"),
34 }
35 }
36}
37
38impl Error for RandomxError {
39 fn description(&self) -> &str {
40 match *self {
41 RandomxError::CacheAllocError => "Failed to allocate cache",
42 RandomxError::DatasetAllocError => "Failed to allocate dataset",
43 RandomxError::VmAllocError => "Failed to create VM",
44 }
45 }
46
47 fn cause(&self) -> Option<&dyn Error> {
48 None
49 }
50}