Skip to content

Commit

Permalink
Add a cmd field on a Nix command failure error
Browse files Browse the repository at this point in the history
  • Loading branch information
W95Psp committed Jul 9, 2023
1 parent 5a00c87 commit 89eb1be
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions typhon/src/nix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ use tokio::process::Command;
#[derive(Debug)]
pub enum Error {
SerdeJson(serde_json::Error),
UnexpectedOutput { context: String },
UnexpectedOutput {
context: String,
},
FromUtf8Error(std::string::FromUtf8Error),
NixCommand { stdout: String, stderr: String },
ExpectedDrvGotAttrset { expr: String },
NixCommand {
cmd: String,
stdout: String,
stderr: String,
},
ExpectedDrvGotAttrset {
expr: String,
},
BuildFailed,
}

Expand Down Expand Up @@ -56,7 +64,11 @@ impl CommandExtTrait for Command {
let stderr = String::from_utf8(nix_output.stderr)?;

if !nix_output.status.success() {
Err(Error::NixCommand { stdout, stderr })
Err(Error::NixCommand {
cmd: format!("{:?}", self),
stdout,
stderr,
})
} else {
Ok(stdout)
}
Expand Down

0 comments on commit 89eb1be

Please sign in to comment.