1pub const OK: i32 = 0;
5pub const FAILED: i32 = 1;
7pub const USAGE: i32 = 2;
9pub const TEMPFAIL: i32 = 75;
11pub const REFUSED: i32 = 78;
14pub const SIGINT: i32 = 130;
16pub const SIGTERM: i32 = 143;
18
19pub const TABLE: &str = "\
21Exit codes:
22 0 all requested work completed
23 1 work attempted and failed (a build line or a phase); see the result file
24 2 usage error, invalid site file, or a tool below its minimum version
25 75 a resource is temporarily unavailable or a step is pending; rerun
26 78 refused by a precondition, by admission or by eb-staged-rebuild; lines
27 built before the refusal stay built, see the result file
28 130 interrupted by SIGINT, after the running child ended
29 143 interrupted by SIGTERM, after the running child ended
30
31Sibling tool codes are mapped explicitly:
32 eb-stack admit 0 admitted, 78 refused, 1 failed, 2 usage
33 eb-stack shard the code in shards.planner_exit_unsharded (default 3) means
34 unsharded; the run continues
35 eb-staged-rebuild 2 is a refusal there; the driver records it as refused
36 (exit 78), 75 as pending (exit 75), any other non-zero as failed
37 eb-keep-logs rotate 75 means another rotate holds the log root's lock;
38 the logs phase is recorded as skipped, any other non-zero
39 as failed
40A signal (130, 143) or a usage error (2) ends the run with that code. Otherwise,
41when several apply: 1, then 78, then 75, then 0. Codes are never summed.";
42
43#[derive(Debug)]
45pub struct Fail {
46 pub code: i32,
48 pub msg: String,
50}
51
52impl Fail {
53 pub fn new(code: i32, msg: impl Into<String>) -> Self {
55 Fail {
56 code,
57 msg: msg.into(),
58 }
59 }
60 pub fn usage(msg: impl Into<String>) -> Self {
63 Fail::new(USAGE, msg)
64 }
65}
66
67impl std::fmt::Display for Fail {
68 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
69 f.write_str(&self.msg)
70 }
71}
72
73impl std::error::Error for Fail {}