summaryrefslogtreecommitdiffstats
path: root/src/review
diff options
context:
space:
mode:
Diffstat (limited to 'src/review')
-rw-r--r--src/review/approve.rs10
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, &note)?;
candidates::resolve_in(tx, candidate_id, CandidateState::Rejected, &at)?;
db::audit_in(