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
use std::{self, io, fmt}; use ::tty; #[derive(Debug)] pub enum Error { Pty(tty::ForkError), Io(io::Error), } impl std::error::Error for Error { fn description(&self) -> &str { "pty-shell error" } fn cause(&self) -> Option<&std::error::Error> { match *self { Error::Pty(ref err) => Some(err), Error::Io(ref err) => Some(err), } } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { std::error::Error::description(self).fmt(f) } } impl From<tty::ForkError> for Error { fn from(err: tty::ForkError) -> Error { Error::Pty(err) } } impl From<io::Error> for Error { fn from(err: io::Error) -> Error { Error::Io(err) } }