Skip to content

Commit 590ba4c

Browse files
committed
Add more error message for conda create env
1 parent 28f915a commit 590ba4c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tests/common/mod.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{bail, Result};
1+
use anyhow::{bail, Context, Result};
22
use fs_err as fs;
33
use maturin::Target;
44
use normpath::PathExt as _;
@@ -85,6 +85,7 @@ pub fn maybe_mock_cargo() {
8585
}
8686

8787
/// Better error formatting
88+
#[track_caller]
8889
pub fn handle_result<T>(result: Result<T>) -> T {
8990
match result {
9091
Err(e) => {
@@ -199,7 +200,21 @@ pub fn create_conda_env(name: &str, major: usize, minor: usize) -> Result<(PathB
199200
.arg("--json")
200201
.output()
201202
.expect("Conda not available.");
202-
let result: CondaCreateResult = serde_json::from_slice(&output.stdout)?;
203+
if !output.status.success() {
204+
panic!(
205+
"Failed to create conda environment: {}\n---stdout:\n{}---stderr:\n{}",
206+
output.status,
207+
str::from_utf8(&output.stdout)?,
208+
str::from_utf8(&output.stderr)?
209+
);
210+
}
211+
let result: CondaCreateResult = serde_json::from_slice(&output.stdout).with_context(|| {
212+
format!(
213+
"Failed to deserialize conda create command output:\n---stdout:\n{}---stderr:\n{}",
214+
str::from_utf8(&output.stdout).unwrap(),
215+
str::from_utf8(&output.stderr).unwrap(),
216+
)
217+
})?;
203218
if !result.success {
204219
bail!("Failed to create conda environment {}.", name);
205220
}

0 commit comments

Comments
 (0)