Added error handling
This commit is contained in:
parent
c411ab30d4
commit
e87920b736
1 changed files with 12 additions and 8 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -310,8 +310,12 @@ Heuristic filter selection strategies:
|
||||||
matches
|
matches
|
||||||
.get_many::<PathBuf>("files")
|
.get_many::<PathBuf>("files")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.cloned()
|
.flat_map(|path| {
|
||||||
.flat_map(apply_glob_pattern)
|
apply_glob_pattern(path).unwrap_or_else(|e| {
|
||||||
|
warn!("{path:?}: {e}");
|
||||||
|
vec![]
|
||||||
|
})
|
||||||
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
matches
|
matches
|
||||||
|
|
@ -392,13 +396,13 @@ fn collect_files(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn apply_glob_pattern(path: PathBuf) -> Vec<PathBuf> {
|
fn apply_glob_pattern(path: &std::path::Path) -> Result<Vec<PathBuf>, String> {
|
||||||
let input_path = path.to_str().unwrap();
|
let input_path = path.to_str().ok_or("Failed to read path.".to_string())?;
|
||||||
|
|
||||||
glob::glob(input_path)
|
Ok(glob::glob(input_path)
|
||||||
.expect("Failed to read glob pattern")
|
.map_err(|e| e.to_string())?
|
||||||
.map(|path| path.unwrap())
|
.flatten()
|
||||||
.collect()
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_opts_into_struct(
|
fn parse_opts_into_struct(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue