1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Better error message when xclip is not available

Resolves #37.
This commit is contained in:
Joe Wilm 2017-01-02 20:15:24 -08:00
parent a105be82cf
commit 06991e6eee
2 changed files with 11 additions and 4 deletions

View file

@ -45,7 +45,14 @@ impl ::std::error::Error for Error {
impl ::std::fmt::Display for Error { impl ::std::fmt::Display for Error {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match *self { match *self {
Error::Io(ref err) => write!(f, "error calling xclip: {}", err), Error::Io(ref err) => {
match err.kind() {
io::ErrorKind::NotFound => {
write!(f, "Please install `xclip` to enable clipboard support")
},
_ => write!(f, "error calling xclip: {}", err),
}
},
Error::Xclip(ref s) => write!(f, "error from xclip: {}", s), Error::Xclip(ref s) => write!(f, "error from xclip: {}", s),
Error::Utf8(ref err) => write!(f, "error parsing xclip output: {}", err), Error::Utf8(ref err) => write!(f, "error parsing xclip output: {}", err),
} }

View file

@ -151,7 +151,7 @@ impl Action {
Clipboard::new() Clipboard::new()
.and_then(|mut clipboard| clipboard.store_primary(buf)) .and_then(|mut clipboard| clipboard.store_primary(buf))
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
err_println!("Error storing selection to clipboard: {}", Red(err)); err_println!("Error storing selection to clipboard. {}", Red(err));
}); });
} }
} }
@ -170,7 +170,7 @@ impl Action {
} }
}) })
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
err_println!("Error loading data from clipboard {}", Red(err)); err_println!("Error loading data from clipboard. {}", Red(err));
}); });
}, },
} }
@ -278,7 +278,7 @@ impl<'a, N: Notify + 'a> Processor<'a, N> {
Clipboard::new() Clipboard::new()
.and_then(|mut clipboard| clipboard.store_selection(buf)) .and_then(|mut clipboard| clipboard.store_selection(buf))
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
err_println!("Error storing selection to clipboard: {}", Red(err)); err_println!("Error storing selection to clipboard. {}", Red(err));
}); });
} }
} }