diff --git a/src/exec/command.rs b/src/exec/command.rs index effc770..1d4f900 100644 --- a/src/exec/command.rs +++ b/src/exec/command.rs @@ -30,10 +30,10 @@ pub fn execute_command(mut cmd: Command, out_perm: Arc>) { let _ = stderr.lock().write_all(&output.stderr); } Err(ref why) if why.kind() == io::ErrorKind::NotFound => { - print_error!("fd: execution error: command not found"); + print_error!("Command not found: {:?}", cmd); } Err(why) => { - print_error!("fd: execution error: {}", why); + print_error!("Problem while executing command: {}", why); } } } diff --git a/src/internal/mod.rs b/src/internal/mod.rs index 7690a6b..250f419 100644 --- a/src/internal/mod.rs +++ b/src/internal/mod.rs @@ -17,7 +17,7 @@ pub mod filter; pub mod opts; macro_rules! print_error { - ($($arg:tt)*) => (eprintln!($($arg)*)) + ($($arg:tt)*) => (eprintln!("[fd error]: {}", format!($($arg)*))) } macro_rules! print_error_and_exit { diff --git a/src/main.rs b/src/main.rs index 52c8323..e792565 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,7 +58,7 @@ fn main() { // Get the current working directory let current_dir = Path::new("."); if !fshelper::is_dir(current_dir) { - print_error_and_exit!("Error: could not get current directory."); + print_error_and_exit!("Could not get current directory."); } // Get one or more root directories to search. @@ -71,7 +71,7 @@ fn main() { let path_buffer = PathBuf::from(path); if !fshelper::is_dir(&path_buffer) { print_error_and_exit!( - "Error: '{}' is not a directory.", + "'{}' is not a directory.", path_buffer.to_string_lossy() ); } @@ -99,7 +99,7 @@ fn main() { && fshelper::is_dir(Path::new(pattern)) { print_error_and_exit!( - "Error: The search pattern '{pattern}' contains a path-separation character ('{sep}') \ + "The search pattern '{pattern}' contains a path-separation character ('{sep}') \ and will not lead to any search results.\n\n\ If you want to search for all files inside the '{pattern}' directory, use a match-all pattern:\n\n \ fd . '{pattern}'\n\n\ @@ -151,7 +151,7 @@ fn main() { if let Some(f) = SizeFilter::from_string(sf) { return f; } - print_error_and_exit!("Error: {} is not a valid size constraint.", sf); + print_error_and_exit!("'{}' is not a valid size constraint. See 'fd --help'.", sf); }) .collect() }) @@ -163,14 +163,14 @@ fn main() { if let Some(f) = TimeFilter::after(&now, t) { time_constraints.push(f); } else { - print_error_and_exit!("Error: {} is not a valid time.", t); + print_error_and_exit!("'{}' is not a valid date or duration. See 'fd --help'.", t); } } if let Some(t) = matches.value_of("changed-before") { if let Some(f) = TimeFilter::before(&now, t) { time_constraints.push(f); } else { - print_error_and_exit!("Error: {} is not a valid time.", t); + print_error_and_exit!("'{}' is not a valid date or duration. See 'fd --help'.", t); } } diff --git a/src/walk.rs b/src/walk.rs index ecd5283..b8a0829 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -62,7 +62,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc, config: Arc) { for pattern in &config.exclude_patterns { let res = override_builder.add(pattern); if res.is_err() { - print_error_and_exit!("Error: malformed exclude pattern '{}'", pattern); + print_error_and_exit!("Malformed exclude pattern '{}'", pattern); } } let overrides = override_builder.build().unwrap_or_else(|_| { @@ -94,7 +94,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc, config: Arc) { print_error!( "{}", format!( - "Error while parsing custom ignore file '{}': {}.", + "Malformed pattern in custom ignore file '{}': {}.", ignore_file.to_string_lossy(), err.description() ) @@ -319,7 +319,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc, config: Arc) { match fshelper::path_absolute_form(entry_path) { Ok(path_abs_buf) => Some(path_abs_buf.to_string_lossy().into_owned().into()), Err(_) => { - print_error_and_exit!("Error: unable to get full path."); + print_error_and_exit!("Unable to retrieve absolute path."); } } } else {