summaryrefslogtreecommitdiffstats
path: root/src/fail.rs
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2019-02-21 21:41:52 +0100
committerrabite <rabite@posteo.de>2019-02-22 00:46:41 +0100
commit3b38143f9bc758b10d76ebae39bca5a15350622b (patch)
tree687dfb1df38bb46d775623579e90ef00f46076ed /src/fail.rs
parentfe542047c231cff6c1959fe05cb51e177ddfbcc6 (diff)
added on_ready support
Diffstat (limited to 'src/fail.rs')
-rw-r--r--src/fail.rs48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/fail.rs b/src/fail.rs
index 791435b..0b9b0b3 100644
--- a/src/fail.rs
+++ b/src/fail.rs
@@ -1,4 +1,6 @@
use failure;
+use failure::Error;
+use failure::{Fail, ResultExt};
pub type HResult<T> = Result<T, HError>;
@@ -8,36 +10,80 @@ pub enum HError {
IoError{#[cause] error: std::io::Error},
#[fail(display = "Mutex failed")]
MutexError,
+ #[fail(display = "Can't lock!")]
+ TryLockError,
#[fail(display = "Channel failed: {}", error)]
ChannelTryRecvError{#[cause] error: std::sync::mpsc::TryRecvError},
+ #[fail(display = "Channel failed: {}", error)]
+ ChannelRecvError{#[cause] error: std::sync::mpsc::RecvError},
+ #[fail(display = "Channel failed")]
+ ChannelSendError,
#[fail(display = "Previewer failed on file: {}", file)]
PreviewFailed{file: String},
#[fail(display = "StalePreviewer for file: {}", file)]
StalePreviewError{file: String},
#[fail(display = "Failed: {}", error)]
- Error{#[cause] error: failure::Error }
+ Error{#[cause] error: failure::Error },
+ #[fail(display = "Was None!")]
+ NoneError,
+ #[fail(display = "Not ready yet!")]
+ WillBeNotReady,
+ #[fail(display = "No widget found")]
+ NoWidgetError
}
impl From<std::io::Error> for HError {
fn from(error: std::io::Error) -> Self {
+ dbg!(&error);
HError::IoError { error: error }
}
}
impl From<failure::Error> for HError {
fn from(error: failure::Error) -> Self {
+ dbg!(&error);
HError::Error { error: error }
}
}
impl From<std::sync::mpsc::TryRecvError> for HError {
fn from(error: std::sync::mpsc::TryRecvError) -> Self {
+ dbg!(&error);
HError::ChannelTryRecvError { error: error }
}
}
+impl From<std::sync::mpsc::RecvError> for HError {
+ fn from(error: std::sync::mpsc::RecvError) -> Self {
+ dbg!(&error);
+ HError::ChannelRecvError { error: error }
+ }
+}
+
+impl<T> From<std::sync::mpsc::SendError<T>> for HError {
+ fn from(error: std::sync::mpsc::SendError<T>) -> Self {
+ dbg!(&error);
+ HError::ChannelSendError
+ }
+}
+
impl<T> From<std::sync::PoisonError<T>> for HError {
fn from(_: std::sync::PoisonError<T>) -> Self {
+ dbg!("Poisoned Mutex");
HError::MutexError
}
}
+
+impl<T> From<std::sync::TryLockError<T>> for HError {
+ fn from(error: std::sync::TryLockError<T>) -> Self {
+ dbg!(&error);
+ HError::TryLockError
+ }
+}
+
+impl From<std::option::NoneError> for HError {
+ fn from(error: std::option::NoneError) -> Self {
+ dbg!(&error);
+ HError::NoneError
+ }
+}