use std::any::Any;
use std::error::Error;
use std::fmt::{self, Display, Formatter};
pub use context::stack::StackError;
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct Dropped;
impl Error for Dropped {
fn description(&self) -> &str {
"The future waited on has been dropped before resolving"
}
}
impl Display for Dropped {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
#[derive(Debug)]
pub enum TaskFailed {
Panicked(Box<Any + Send + 'static>),
PanicPropagated,
Lost,
}
impl Error for TaskFailed {
fn description(&self) -> &str {
match *self {
TaskFailed::Panicked(_) | TaskFailed::PanicPropagated => "The coroutine panicked",
TaskFailed::Lost => "The coroutine was lost",
}
}
}
impl Display for TaskFailed {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}