Skip to content

Commit 1a86a2e

Browse files
committed
Replace expect calls with proper errors
1 parent 697a384 commit 1a86a2e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/args/build.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{anyhow, Result};
1+
use anyhow::{anyhow, Context, Result};
22
use std::{
33
mem,
44
path::{Path, PathBuf},
@@ -48,11 +48,10 @@ impl BuildCommand {
4848
let next = arg_iter.next();
4949
set(
5050
&mut manifest_path,
51-
next.as_ref().map(|p| {
52-
Path::new(&p)
53-
.canonicalize()
54-
.expect("--manifest-path invalid")
55-
}),
51+
next.as_ref()
52+
.map(|p| Path::new(&p).canonicalize())
53+
.transpose()
54+
.context("--manifest-path invalid")?,
5655
)?;
5756
cargo_args.push(arg);
5857
if let Some(next) = next {
@@ -62,7 +61,7 @@ impl BuildCommand {
6261
_ if arg.starts_with("--manifest-path=") => {
6362
let path = Path::new(arg.trim_start_matches("--manifest-path="))
6463
.canonicalize()
65-
.expect("--manifest-path invalid");
64+
.context("--manifest-path invalid")?;
6665
set(&mut manifest_path, Some(path))?;
6766
cargo_args.push(arg);
6867
}

0 commit comments

Comments
 (0)