git: Improve error messages (#35946)
Release Notes: - Improved git error messages Includes stderr in the error message for git commands, provides better output for things like errors when switching branches. Before: <img width="702" height="330" alt="image" src="https://github.com/user-attachments/assets/f32402ae-b85c-4b0b-aae8-789607e8ec9e" /> After: <img width="650" height="575" alt="image" src="https://github.com/user-attachments/assets/308dbe3c-1ff9-40b9-a187-1e12d2488c80" /> --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
@@ -1814,6 +1814,7 @@ impl GitBinary {
|
||||
output.status.success(),
|
||||
GitBinaryCommandError {
|
||||
stdout: String::from_utf8_lossy(&output.stdout).to_string(),
|
||||
stderr: String::from_utf8_lossy(&output.stderr).to_string(),
|
||||
status: output.status,
|
||||
}
|
||||
);
|
||||
@@ -1836,9 +1837,10 @@ impl GitBinary {
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("Git command failed: {stdout}")]
|
||||
#[error("Git command failed:\n{stdout}{stderr}\n")]
|
||||
struct GitBinaryCommandError {
|
||||
stdout: String,
|
||||
stderr: String,
|
||||
status: ExitStatus,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user