1use std;
18
19#[derive(Debug)]
21pub enum Error {
22 BadFileSize,
24
25 IOError(std::io::Error),
27
28 NotImplementedYet,
30
31 InvalidOLEFile,
33
34 BadSizeValue(&'static str),
36
37 EmptyMasterSectorAllocationTable,
39
40 NotSectorUsedBySAT,
42
43 NodeTypeUnknown,
45
46 BadRootStorageSize,
48
49 EmptyEntry,
51}
52
53impl std::error::Error for Error {
54 fn description(&self) -> &str {
55 match *self {
56 Error::BadFileSize => "Filesize is null or too big.",
57 Error::IOError(ref e) => e.description(),
58 Error::NotImplementedYet => "Method not implemented yet",
59 Error::InvalidOLEFile => "Invalid OLE File",
60 Error::BadSizeValue(ref e) => e,
61 Error::EmptyMasterSectorAllocationTable => "MSAT is empty",
62 Error::NotSectorUsedBySAT => "Sector is not a sector used by the SAT.",
63 Error::NodeTypeUnknown => "Unknown node type",
64 Error::BadRootStorageSize => "Bad RootStorage size",
65 Error::EmptyEntry => "Empty entry"
66 }
67 }
68
69 fn cause(&self) -> Option<&std::error::Error> {
70 match *self {
71 Error::IOError(ref e) => Some(e),
72 _ => None
73 }
74 }
75}
76
77impl std::fmt::Display for Error {
78 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
79 use std::error::Error;
80 write!(f, "{}", self.description())
81 }
82}