#[non_exhaustive]pub enum Error {
Spawn {
program: String,
source: Error,
},
Exit {
program: String,
code: i32,
stdout: String,
stderr: String,
},
Timeout {
program: String,
timeout: Duration,
},
NotReady {
program: String,
timeout: Duration,
},
Parse {
program: String,
message: String,
},
Unsupported {
operation: String,
},
Cancelled {
program: String,
},
Io(Error),
}Expand description
Errors produced when launching or running a child process.
Spawn failures, a non-zero exit (Exit), timeouts, and IO
errors fold into one structured enum, so callers can pattern-match on the
failure mode instead of parsing strings.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Spawn
The child process could not be started (binary not found, permission denied, …).
Exit
The process ran to completion but exited with a non-zero status.
Produced by the ensure_success helpers; the raw exit code is otherwise
reported without erroring (a non-zero exit is not inherently a failure).
Both captured streams are carried (each truncated to 4 KiB): git/jj
write decisive diagnostics to stdout on failure (CONFLICT (content): …, nothing to commit, working tree clean), so a caller building a
user-facing message wants stdout as a fallback when stderr is empty — see
diagnostic.
The one-line Display message appends the last non-empty line of
diagnostic, capped at 200 bytes — `git` exited with code 2: fatal: boom — actionable in a log line without dumping
multi-KiB streams into it.
Fields
Timeout
The process exceeded its configured timeout and was killed.
NotReady
A readiness probe (RunningProcess::wait_for_line,
wait_for_port,
wait_for) did not pass within its
deadline — the line never appeared, the port never accepted, the check
never returned true, or the child exited before becoming ready.
Distinct from Timeout: a probe deadline is separate
from the run’s own Command::timeout, and a
failed probe does not kill the child — the caller decides what
happens next.
Fields
Parse
The process succeeded but its output could not be parsed into the
expected shape (e.g. malformed --json). Produced by the fallible-parse
helpers on CliClient.
Unsupported
An operation is not supported by the active containment mechanism on this platform.
Raised by ProcessGroup::signal for any signal other than
Signal::Kill on Windows (Job Objects have no POSIX signals), and by
signal/suspend/resume on the no-containment target, which has no
process tree to act on.
Cancelled
cancellation only.The run was cancelled via its CancellationToken
(Command::cancel_on) and its process
tree was killed.
Asymmetric with Timeout by design: a timeout is
captured (ProcessResult::timed_out) on the non-checking paths,
whereas a cancellation is always raised on every consuming path.
When a run both times out and is cancelled, cancellation wins (it is
checked first).
Io(Error)
An IO error occurred while driving the process (reading a pipe, writing stdin, waiting for exit).
Implementations§
Source§impl Error
impl Error
Sourcepub fn diagnostic(&self) -> Option<&str>
pub fn diagnostic(&self) -> Option<&str>
The best human-facing message for a failed run, trimmed of surrounding
whitespace: captured standard error if it carries text, otherwise the
captured standard output (where git puts CONFLICT … and git commit
puts nothing to commit). Returns None when there is no captured output
to show — a silent Exit (both streams blank) or any
non-Exit variant (Spawn, Timeout,
Parse, Io) — so a caller can fall back to
the Display message. For the raw, untrimmed stream
match on Exit’s fields directly.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()