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