bootstrap: Optionally print a backtrace if a command fails

This commit is contained in:
Jynn Nelson
2026-03-16 14:33:39 +01:00
parent eaf4e7489b
commit c8a2c46eda
+11
View File
@@ -7,6 +7,7 @@
//! relevant to command execution in the bootstrap process. This includes settings such as
//! dry-run mode, verbosity level, and failure behavior.
use std::backtrace::{Backtrace, BacktraceStatus};
use std::collections::HashMap;
use std::ffi::{OsStr, OsString};
use std::fmt::{Debug, Formatter};
@@ -930,6 +931,16 @@ enum FailureReason {
if stderr.captures() {
writeln!(error_message, "\n--- STDERR vvv\n{}", output.stderr().trim()).unwrap();
}
let backtrace = if exec_ctx.verbosity > 1 {
Backtrace::force_capture()
} else if matches!(command.failure_behavior, BehaviorOnFailure::Ignore) {
Backtrace::disabled()
} else {
Backtrace::capture()
};
if matches!(backtrace.status(), BacktraceStatus::Captured) {
writeln!(error_message, "\n--- BACKTRACE vvv\n{backtrace}").unwrap();
}
match command.failure_behavior {
BehaviorOnFailure::DelayFail => {