diff options
author | Kyohei Uto <im@kyoheiu.dev> | 2024-01-20 07:28:19 +0900 |
---|---|---|
committer | Kyohei Uto <im@kyoheiu.dev> | 2024-01-20 07:28:19 +0900 |
commit | 67e13674f5aac693d617a879be2d7faa2f95c9c3 (patch) | |
tree | 57fd6cd001e7c025aeb3c15600bf17e398790b9a | |
parent | 572802f0957b154546b9b2c89f0b8de6f69b90cc (diff) |
Error handling for target path
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index d3fd81b..aa76aff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,13 +48,16 @@ fn main() -> Result<(), errors::FxError> { } _ => { if args[1].starts_with("--choosefiles=") { - let target_path = PathBuf::from(args[1].split('=').nth(1).unwrap()); - if let Err(e) = run::run( - std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")), - false, - Some(target_path), - ) { - eprintln!("{}", e); + if let Some(target_path) = args[1].split('=').nth(1) { + if let Err(e) = run::run( + std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")), + false, + Some(PathBuf::from(target_path)), + ) { + eprintln!("{}", e); + } + } else { + eprintln!("Cannot read target file path."); } } else if let Err(e) = run::run(PathBuf::from(&args[1]), false, None) { eprintln!("{}", e); |