Add support to speicfy exit code when error happened

This commit is contained in:
2025-11-03 22:46:45 +08:00
parent 5df59d6345
commit 0e4b308433
4 changed files with 38 additions and 4 deletions

View File

@@ -44,6 +44,19 @@ impl Counter {
ScriptResult::Uncount => {}
}
}
/// Returns true if all jobs failed. (ok == 0 && error > 0)
pub fn all_failed(&self) -> bool {
let ok = self.ok.load(SeqCst);
let error = self.error.load(SeqCst);
ok == 0 && error > 0
}
/// Returns true if there were any errors.
pub fn has_error(&self) -> bool {
let error = self.error.load(SeqCst);
error > 0
}
}
impl std::fmt::Display for Counter {