-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1675 from fermyon/remove-spurious-failure
Exit early when trigger process fails
- Loading branch information
Showing
5 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
pub mod build_info; | ||
pub mod commands; | ||
pub(crate) mod opts; | ||
pub mod subprocess; | ||
mod watch_filter; | ||
mod watch_state; | ||
|
||
pub use crate::opts::HELP_ARGS_ONLY_TRIGGER_TYPE; | ||
pub use opts::HELP_ARGS_ONLY_TRIGGER_TYPE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/// An error representing a subprocess that errored | ||
/// | ||
/// This can be used to propogate a subprocesses exit status. | ||
/// When this error is encountered the cli will exit with the status code | ||
/// instead of printing an error, | ||
#[derive(Debug)] | ||
pub struct ExitStatusError { | ||
status: Option<i32>, | ||
} | ||
|
||
impl ExitStatusError { | ||
pub(crate) fn new(status: std::process::ExitStatus) -> Self { | ||
Self { | ||
status: status.code(), | ||
} | ||
} | ||
|
||
pub fn code(&self) -> i32 { | ||
self.status.unwrap_or(1) | ||
} | ||
} | ||
|
||
impl std::error::Error for ExitStatusError {} | ||
|
||
impl std::fmt::Display for ExitStatusError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
let _ = write!(f, "subprocess exited with status: "); | ||
if let Some(status) = self.status { | ||
writeln!(f, "{}", status) | ||
} else { | ||
writeln!(f, "unknown") | ||
} | ||
} | ||
} |