msgpack/
pack_error.rs

1use std::error;
2use std::fmt::{self, Display, Formatter};
3use std::io::Error;
4
5#[derive(Debug)]
6pub enum PackError {
7    WriteError(Error),
8}
9
10impl From<Error> for PackError {
11    fn from(err: Error) -> PackError {
12        PackError::WriteError(err)
13    }
14}
15
16impl Display for PackError {
17    fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
18        error::Error::description(self).fmt(f)
19    }
20}
21
22impl error::Error for PackError {
23    fn description(&self) -> &str {
24        match *self {
25            PackError::WriteError(..) => "failed to write data",
26        }
27    }
28
29    fn cause(&self) -> Option<&error::Error> {
30        match *self {
31            PackError::WriteError(ref e) => Some(e),
32        }
33    }
34}