use std;
#[derive(Debug)]
pub enum Error {
BadFileSize,
IOError(std::io::Error),
NotImplementedYet,
InvalidOLEFile,
BadSizeValue(&'static str),
EmptyMasterSectorAllocationTable,
NotSectorUsedBySAT,
NodeTypeUnknown,
BadRootStorageSize,
EmptyEntry,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self {
Error::BadFileSize => write!(f, "Filesize is null or too big."),
Error::IOError(ref e) => write!(f, "{}", e.to_string()),
Error::NotImplementedYet => write!(f, "Method not implemented yet"),
Error::InvalidOLEFile => write!(f, "Invalid OLE File"),
Error::BadSizeValue(ref e) => write!(f, "{}", e.to_string()),
Error::EmptyMasterSectorAllocationTable => write!(f, "MSAT is empty"),
Error::NotSectorUsedBySAT => write!(f, "Sector is not a sector used by the SAT."),
Error::NodeTypeUnknown => write!(f, "Unknown node type"),
Error::BadRootStorageSize => write!(f, "Bad RootStorage size"),
Error::EmptyEntry => write!(f, "Empty entry")
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match *self {
Error::IOError(ref e) => Some(e),
_ => None
}
}
}