Skip to content

Commit

Permalink
Improve error handling in scripts init (RustScan#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
bergabman authored Oct 24, 2020
1 parent f9a7586 commit 21b92a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,18 @@ fn main() {

debug!("Main() `opts` arguments are {:?}", opts);

let scripts_to_run: Vec<ScriptFile> =
init_scripts(opts.scripts).expect("could not initiate scripting part.");
let scripts_to_run: Vec<ScriptFile> = match init_scripts(opts.scripts) {
Ok(scripts_to_run) => scripts_to_run,
Err(e) => {
warning!(
format!("Initiating scripts failed!\n{}", e.to_string()),
opts.greppable,
opts.accessible
);
std::process::exit(1);
}
};

debug!("Scripts initialized {:?}", &scripts_to_run);

if !opts.greppable && !opts.accessible {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub fn find_scripts(mut path: PathBuf) -> Result<Vec<PathBuf>> {
}
Ok(files_vec)
} else {
Err(anyhow!("Can't find scripts folder"))
Err(anyhow!("Can't find scripts folder {}", path.display()))
}
}

Expand Down

0 comments on commit 21b92a1

Please sign in to comment.