cleanup: prettier error handling
This commit is contained in:
parent
4492880de3
commit
9341cc08e8
1 changed files with 8 additions and 10 deletions
18
src/lib.rs
18
src/lib.rs
|
|
@ -120,16 +120,14 @@ impl Clipboard {
|
||||||
{
|
{
|
||||||
let _ = self.request_sender.send(worker::Command::Load(T::allowed().to_vec(), target));
|
let _ = self.request_sender.send(worker::Command::Load(T::allowed().to_vec(), target));
|
||||||
|
|
||||||
if let Ok(reply) = self.request_receiver.recv() {
|
match self.request_receiver.recv() {
|
||||||
match reply {
|
Ok(res) => res.and_then(|(data, mime)| {
|
||||||
Ok((data, mime)) => T::try_from((data, mime))
|
T::try_from((data, mime))
|
||||||
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err)),
|
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))
|
||||||
Err(err) => Err(err),
|
}),
|
||||||
}
|
// The clipboard thread is dead, however we shouldn't crash downstream,
|
||||||
} else {
|
// so propogating an error.
|
||||||
// The clipboard thread is dead, however we shouldn't crash downstream, so
|
Err(_) => Err(std::io::Error::new(std::io::ErrorKind::Other, "clipboard is dead.")),
|
||||||
// propogating an error.
|
|
||||||
Err(std::io::Error::new(std::io::ErrorKind::Other, "clipboard is dead."))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue