1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use std::{fmt, error};
#[derive(Debug, Copy, Clone)]
pub enum Error {
NotInitialized(&'static str),
AllocFailed(&'static str),
BadParam(&'static str),
InternalError(&'static str),
InvalidValue(&'static str),
ArchMismatch(&'static str),
MappingError(&'static str),
ExecutionFailed(&'static str),
NotSupported(&'static str),
LicenseError(&'static str),
Unknown(&'static str),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::NotInitialized(ref err) => write!(f, "{:?}", err),
Error::AllocFailed(ref err) => write!(f, "{:?}", err),
Error::BadParam(ref err) => write!(f, "{:?}", err),
Error::InternalError(ref err) => write!(f, "{:?}", err),
Error::InvalidValue(ref err) => write!(f, "{:?}", err),
Error::ArchMismatch(ref err) => write!(f, "{:?}", err),
Error::MappingError(ref err) => write!(f, "{:?}", err),
Error::ExecutionFailed(ref err) => write!(f, "{:?}", err),
Error::NotSupported(ref err) => write!(f, "{:?}", err),
Error::LicenseError(ref err) => write!(f, "{:?}", err),
Error::Unknown(ref err) => write!(f, "{:?}", err),
}
}
}
impl error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::NotInitialized(ref err) => err,
Error::AllocFailed(ref err) => err,
Error::BadParam(ref err) => err,
Error::InternalError(ref err) => err,
Error::InvalidValue(ref err) => err,
Error::ArchMismatch(ref err) => err,
Error::MappingError(ref err) => err,
Error::ExecutionFailed(ref err) => err,
Error::NotSupported(ref err) => err,
Error::LicenseError(ref err) => err,
Error::Unknown(ref err) => err,
}
}
fn cause(&self) -> Option<&error::Error> {
match *self {
Error::NotInitialized(_) => None,
Error::AllocFailed(_) => None,
Error::BadParam(_) => None,
Error::InternalError(_) => None,
Error::InvalidValue(_) => None,
Error::ArchMismatch(_) => None,
Error::MappingError(_) => None,
Error::ExecutionFailed(_) => None,
Error::NotSupported(_) => None,
Error::LicenseError(_) => None,
Error::Unknown(_) => None,
}
}
}