|
@@ -1,21 +1,40 @@
|
|
#[cfg(feature = "clipboard")]
|
|
#[cfg(feature = "clipboard")]
|
|
extern crate clipboard;
|
|
extern crate clipboard;
|
|
|
|
+extern crate failure;
|
|
extern crate open;
|
|
extern crate open;
|
|
|
|
|
|
#[cfg(feature = "clipboard")]
|
|
#[cfg(feature = "clipboard")]
|
|
-use std::error::Error;
|
|
|
|
|
|
+use std::error::Error as StdError;
|
|
|
|
+use std::fmt::{Debug, Display};
|
|
use std::io::Error as IoError;
|
|
use std::io::Error as IoError;
|
|
use std::process::{exit, ExitStatus};
|
|
use std::process::{exit, ExitStatus};
|
|
|
|
|
|
#[cfg(feature = "clipboard")]
|
|
#[cfg(feature = "clipboard")]
|
|
use self::clipboard::{ClipboardContext, ClipboardProvider};
|
|
use self::clipboard::{ClipboardContext, ClipboardProvider};
|
|
|
|
+use self::failure::{Fail};
|
|
use ffsend_api::url::Url;
|
|
use ffsend_api::url::Url;
|
|
|
|
|
|
|
|
+/// Quit the application with an error code,
|
|
|
|
+/// and print the given error.
|
|
|
|
+pub fn quit_error<E: Fail>(err: E) -> ! {
|
|
|
|
+ // Print the error message
|
|
|
|
+ eprintln!("error: {}", err);
|
|
|
|
+
|
|
|
|
+ // Quit
|
|
|
|
+ exit(1);
|
|
|
|
+}
|
|
|
|
+
|
|
/// Quit the application with an error code,
|
|
/// Quit the application with an error code,
|
|
/// and print the given error message.
|
|
/// and print the given error message.
|
|
-pub fn quit_error<S: AsRef<str>>(err: S) -> ! {
|
|
|
|
|
|
+pub fn quit_error_msg<S>(err: S) -> !
|
|
|
|
+ where
|
|
|
|
+ S: AsRef<str> + Display + Debug + Sync + Send + 'static
|
|
|
|
+{
|
|
|
|
+ // TODO: forward the error the `quit_error` here
|
|
|
|
+ // quit_error(failure::err_msg(err));
|
|
|
|
+
|
|
// Print the error message
|
|
// Print the error message
|
|
- eprintln!("error: {}", err.as_ref());
|
|
|
|
|
|
+ eprintln!("error: {}", err);
|
|
|
|
|
|
// Quit
|
|
// Quit
|
|
exit(1);
|
|
exit(1);
|
|
@@ -35,7 +54,7 @@ pub fn open_path(path: &str) -> Result<ExitStatus, IoError> {
|
|
|
|
|
|
/// Set the clipboard of the user to the given `content` string.
|
|
/// Set the clipboard of the user to the given `content` string.
|
|
#[cfg(feature = "clipboard")]
|
|
#[cfg(feature = "clipboard")]
|
|
-pub fn set_clipboard(content: String) -> Result<(), Box<Error>> {
|
|
|
|
|
|
+pub fn set_clipboard(content: String) -> Result<(), Box<StdError>> {
|
|
let mut context: ClipboardContext = ClipboardProvider::new()?;
|
|
let mut context: ClipboardContext = ClipboardProvider::new()?;
|
|
context.set_contents(content)
|
|
context.set_contents(content)
|
|
}
|
|
}
|