use std::{
error::Error,
fmt,
fmt::{Display, Formatter},
};
use windows::Win32::Foundation::HANDLE;
#[derive(Debug)]
pub enum HoudiniError {
CouldNotGetModuleName,
CouldNotAcquireHandle,
CouldNotRenameToStream,
CouldNotDisposeFile,
CouldNotCloseHandle(HANDLE),
UnsupportedPlatform,
}
impl Error for HoudiniError {}
impl Display for HoudiniError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match *self {
HoudiniError::UnsupportedPlatform => write!(f, "this platform is not supported"),
HoudiniError::CouldNotGetModuleName => write!(f, "failed to get the module name"),
HoudiniError::CouldNotAcquireHandle => {
write!(f, "failed to acquire handle for the current process")
},
HoudiniError::CouldNotRenameToStream => write!(f, "failed to rename to stream"),
HoudiniError::CouldNotDisposeFile => write!(f, "failed to dispose file"),
HoudiniError::CouldNotCloseHandle(handle) => {
write!(f, "could not close handle: {:?}", handle)
},
}
}
}