Skip to content

Commit

Permalink
add PoisonedError(String) to Error enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime2 committed Aug 5, 2019
1 parent 436b2db commit aa91c39
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use libcommon_rs::errors::Error as BaseError;
use std::error::Error as StdError;
use std::sync::{MutexGuard, PoisonError};

pub type Result<T> = std::result::Result<T, Error>;

Expand All @@ -11,6 +13,7 @@ pub enum Error {
Io(std::io::Error),
// Indicating read/write operation was unable to read/write complete size of data
Incomplete,
PoisonError(String),
}

impl From<BaseError> for Error {
Expand All @@ -34,6 +37,12 @@ impl From<std::io::Error> for Error {
}
}

impl<'a, T> From<PoisonError<MutexGuard<'a, T>>> for Error {
fn from(e: PoisonError<MutexGuard<'a, T>>) -> Error {
Error::PoisonError(e.description().to_string())
}
}

#[macro_export]
macro_rules! none_error {
() => {
Expand Down

0 comments on commit aa91c39

Please sign in to comment.