blob: 57d636aa7f959ef61224555c2c70b902e1e34f70 (
plain) (
blame)
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
|
use std::{
error,
fmt,
io,
};
use utils::NotmuchEnum;
use ffi;
#[derive(Debug)]
pub enum Error {
IoError(io::Error),
NotmuchError(ffi::NotmuchStatus),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", error::Error::description(self))
}
}
impl error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::IoError(ref e) => error::Error::description(e),
Error::NotmuchError(ref e) => e.description(),
}
}
}
impl error::FromError<io::Error> for Error {
fn from_error(err: io::Error) -> Error {
Error::IoError(err)
}
}
impl error::FromError<ffi::NotmuchStatus> for Error {
fn from_error(err: ffi::NotmuchStatus) -> Error {
Error::NotmuchError(err)
}
}
impl error::FromError<ffi::notmuch_status_t> for Error {
fn from_error(err: ffi::notmuch_status_t) -> Error {
Error::NotmuchError(ffi::NotmuchStatus::from_notmuch_t(err))
}
}
|