1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
use failure;
use failure::Fail;
use std::path::PathBuf;
pub type HResult<T> = Result<T, HError>;
#[derive(Fail, Debug)]
pub enum HError {
#[fail(display = "IO error: {}", error)]
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 },
#[fail(display = "Was None!")]
NoneError,
#[fail(display = "Not ready yet!")]
WillBeNotReady,
#[fail(display = "No widget found")]
NoWidgetError,
#[fail(display = "Path: {:?} not in this directory: {:?}", path, dir)]
WrongDirectoryError{ path: PathBuf, dir: PathBuf },
#[fail(display = "Widget finnished")]
PopupFinnished,
#[fail(display = "Input finnished")]
InputFinnished,
}
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
}
}
|