use std;
use ole;
#[derive(Debug)]
pub enum Error {
OLEError(ole::Error),
NotThumbsDbFile,
IOError(std::io::Error),
NotJPEGFile,
NoEntryAssociated
}
impl std::error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::OLEError(ref e) => e.description(),
Error::NotThumbsDbFile => "This file doesn't seem to be a Thumbs.db",
Error::IOError(ref e) => e.description(),
Error::NotJPEGFile => "This thumbnail is not a JPEG file",
Error::NoEntryAssociated => "Unable to find an entry for this thumbnail"
}
}
fn cause(&self) -> Option<&std::error::Error> {
match *self {
Error::OLEError(ref e) => Some(e),
Error::NotThumbsDbFile => None,
Error::IOError(ref e) => Some(e),
Error::NotJPEGFile => None,
Error::NoEntryAssociated => 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())
}
}