diff options
| author | dev <dev@localhost> | 2026-11-20 18:20:18 +0000 |
|---|---|---|
| committer | dev <dev@localhost> | 2026-11-20 18:20:18 +0000 |
| commit | bbae6c8e83cf145f9af472f69591bae804d03048 (patch) | |
| tree | bf8f8562b6e78fe140128f32ecf788278c2d35f3 /src/review/approve.rs | |
| parent | a97e5dc40069b0dc13c28fa9ab3202c8e5012038 (diff) | |
| download | aur-build-bbae6c8e83cf145f9af472f69591bae804d03048.tar.gz aur-build-bbae6c8e83cf145f9af472f69591bae804d03048.zip | |
error: give the six variants behavior carries a shape, not a sentence
`Error::NotFound("no repo row; run `aur-build init`")` and
`Error::NotFound("pkgbase linux")` were the same variant. One is "the install
was never initialised, every page is wrong"; the other is "that page does not
exist, answer 404". The difference lived inside a string, so the only way to
act on it was to re-parse text the same process had written moments earlier.
Six variants now carry structure:
Missing pkgbase / candidate / release / build / snapshot /
mirror path / repo row
Refused IllegalTransition / WrongState / PointerMoved / Other
Guard HashMismatch / DigestMismatch / Invariant
WorldGap MissingPin / Other
PoolFull Backend{backend} / Other
TransientCause Upstream / Command / Other
`Refused` distinguishes the three refusals that were indistinguishable: a
transition no edge permits (caller bug), a row in the wrong state (stale
view), and the accepted pointer moving under a build (a lost race, and the
one a client may safely retry). `PoolFull::Backend` names which pool, because
a kata quota needs an operator and a local cap clears when a build exits.
`is_transient` and `is_pool_exhausted` already matched on variants rather than
strings, so they are unchanged — the typing is what lets the *next* branch be
a match instead of a `contains`.
No test assertion was edited. Where a message is load-bearing the Display was
written to reproduce it: `recipe_hash mismatch: approved X, materialized Y`,
`no release 4`, `illegal candidate transition approved → rejected`, `sandbox
world is missing plain-make-1.0-1 after installing the lease set` and kata's
`never dialed in` all come out of the new types byte-identical. Five messages
did change wording, none asserted anywhere:
release N is X, not published: nothing to withdraw
-> release N is X, not published (Refused::WrongState's shape)
illegal candidate transition a → b for review 7
-> ... for candidate 7 (it is a candidate id; "review"
was misleading)
no candidate 7 to resolve -> candidate 7 (Missing::Candidate's shape)
lease artifact n-v: store bytes hash to A but the index says B
-> source n-v hashed to A but the candidate recorded B (shares
Guard::DigestMismatch with the source-cache check)
vcs_cache clone URL: err -> upstream: vcs_cache clone URL: err
(TransientCause::Upstream tag)
error.pub 15->21 is the six payload enums, which is the point of the task
rather than a widening to apologise for. watch.dead/test each rose by one for
a subtler reason: `watch::upstream::resolve` looked live only because an
unrelated db message ended "... to resolve", and rewording that string removed
the phantom mention. The census now documents that a clean count is not always
an answer, since mentions are matched over raw source including string
literals.
281 passed / 0 failed (277 plus four new typing tests in src/error.rs), clippy
-D warnings clean, release build clean.
Diffstat (limited to 'src/review/approve.rs')
| -rw-r--r-- | src/review/approve.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/review/approve.rs b/src/review/approve.rs index 79726ca..adc81c0 100644 --- a/src/review/approve.rs +++ b/src/review/approve.rs @@ -1,5 +1,5 @@ use crate::db::{self, approvals, candidates, CandidateState, *}; -use crate::error::{Error, Result}; +use crate::error::{Error, Missing, Refused, Result}; use crate::time; #[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] @@ -48,7 +48,7 @@ pub fn approve( db.writer.tx(move |tx| -> Result<std::result::Result<Approval, ApproveError>> { let subject = candidates::review_subject_in(tx, candidate_id)? - .ok_or_else(|| Error::not_found(format!("candidate {candidate_id}")))?; + .ok_or_else(|| Error::not_found(Missing::Candidate(candidate_id)))?; let id = subject.id; let base = subject.base_release_id; let current_base = subject.current_base_release_id; @@ -109,12 +109,12 @@ pub fn reject(db: &Db, actor: &str, candidate_id: i64, note: &str) -> Result<()> let at = time::now(); db.writer.tx(move |tx| { let state = candidates::state_in(tx, candidate_id)? - .ok_or_else(|| Error::not_found(format!("candidate {candidate_id}")))?; + .ok_or_else(|| Error::not_found(Missing::Candidate(candidate_id)))?; if !state.is_open() { - return Err(Error::conflict(format!("candidate is {state}, not pending"))); + return Err(Error::conflict(Refused::WrongState { entity: "candidate", id: candidate_id.to_string(), found: state.to_string(), expected: "pending" })); } let identity = candidates::identity_in(tx, candidate_id)? - .ok_or_else(|| Error::not_found(format!("candidate {candidate_id}")))?; + .ok_or_else(|| Error::not_found(Missing::Candidate(candidate_id)))?; approvals::record_rejection_in(tx, candidate_id, &at, &identity, ¬e)?; candidates::resolve_in(tx, candidate_id, CandidateState::Rejected, &at)?; db::audit_in( |
