parallel_event_emitter/
error.rs

1//! Error definitions
2
3use std::error::Error;
4use std::fmt::{Display, Formatter, Result as FmtResult};
5use std::sync::PoisonError;
6
7use trace_error::*;
8
9/// Shorthand result type for `EventError`s
10pub type EventResult<T> = TraceResult<T, EventError>;
11
12/// Error variants for event emitters
13#[derive(Debug)]
14pub enum EventError {
15    /// Converted from a `PoisonError<T>` to remove the `T`.
16    ///
17    /// Still means the same thing, that a lock was poisoned by a panicking thread.
18    PoisonError,
19}
20
21impl Display for EventError {
22    fn fmt(&self, f: &mut Formatter) -> FmtResult {
23        write!(f, "{}", self.description())
24    }
25}
26
27impl Error for EventError {
28    fn description(&self) -> &str {
29        match *self {
30            EventError::PoisonError => "Poison Error",
31        }
32    }
33}
34
35impl<T> From<PoisonError<T>> for EventError {
36    fn from(_: PoisonError<T>) -> EventError {
37        EventError::PoisonError
38    }
39}