From 84f0cc0fe17dc850aea33f43c6642de1dd809dc2 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Fri, 11 Oct 2024 20:45:36 -0700 Subject: [PATCH] Better error message if `cargo metadata` fails --- cargo-insta/src/cli.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs index dd42ae00..e377c2ef 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -442,7 +442,12 @@ fn handle_target_args<'a>( (None, None) => {} }; - let metadata = cmd.exec()?; + let metadata = cmd.exec().map_err(|e| { + format!( + "failed to load cargo metadata: {}. Command details: {:?}", + e, cmd + ) + })?; let workspace_root = metadata.workspace_root.as_std_path().to_path_buf(); let tool_config = ToolConfig::from_workspace(&workspace_root)?;