MCPcopy Create free account
hub / github.com/cargo-lambda/cargo-lambda / capture_error

Function capture_error

crates/cargo-lambda-interactive/src/command.rs:46–75  ·  view source on GitHub ↗
(
    cmd: &str,
    args: &[&str],
    child: Option<&mut Child>,
    error: Option<std::io::Error>,
)

Source from the content-addressed store, hash-verified

44}
45
46async fn capture_error(
47 cmd: &str,
48 args: &[&str],
49 child: Option<&mut Child>,
50 error: Option<std::io::Error>,
51) -> CommandError {
52 let mut stdout = Vec::new();
53 let mut stderr = Vec::new();
54
55 if let Some(child) = child {
56 let mut reader = child.stdout.take().expect("stdout is not captured");
57 reader
58 .read_to_end(&mut stdout)
59 .await
60 .expect("Failed to read stdout");
61
62 let mut reader = child.stderr.take().expect("stderr is not captured");
63 reader
64 .read_to_end(&mut stderr)
65 .await
66 .expect("Failed to read stderr");
67 }
68
69 CommandError {
70 command: format!("{} {}", cmd, args.join(" ")),
71 stdout,
72 stderr,
73 error,
74 }
75}
76
77#[derive(Debug, Default, Diagnostic)]
78#[diagnostic(code(command_error))]

Callers 1

silent_commandFunction · 0.85

Calls 1

newFunction · 0.85

Tested by

no test coverage detected