Make sure a command finished successfully, otherwise throw an error.
(output: &Output, message: String)
| 4 | |
| 5 | /// Make sure a command finished successfully, otherwise throw an error. |
| 6 | pub fn ensure_success(output: &Output, message: String) -> Result<(), Error> { |
| 7 | let stderr = String::from_utf8_lossy(&output.stderr).to_string(); |
| 8 | let stdout = String::from_utf8_lossy(&output.stdout).to_string(); |
| 9 | |
| 10 | if !output.status.success() { |
| 11 | return Err(Error::CommandFailed { |
| 12 | message, |
| 13 | stdout, |
| 14 | stderr, |
| 15 | }); |
| 16 | } |
| 17 | |
| 18 | Ok(()) |
| 19 | } |
no outgoing calls
no test coverage detected