use ::descriptor::DescriptorError;
use std::error::Error;
use std::fmt;
pub type Result<T> = ::std::result::Result<T, SlaveError>;
#[derive(Clone, Copy, Debug)]
pub enum SlaveError {
BadDescriptor(DescriptorError),
Dup2Error,
}
impl fmt::Display for SlaveError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", ::errno::errno())
}
}
impl Error for SlaveError {
fn description(&self) -> &str {
match *self {
SlaveError::BadDescriptor(_) => "the descriptor as occured an error",
SlaveError::Dup2Error => "the `dup2` has a error, errno isset appropriately.",
}
}
fn cause(&self) -> Option<&Error> {
match *self {
SlaveError::BadDescriptor(ref err) => Some(err),
_ => None,
}
}
}