aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rust/src/api_helpers.rs5
-rw-r--r--rust/src/api_server.rs5
-rw-r--r--rust/src/api_wrappers.rs5
-rw-r--r--rust/src/lib.rs4
4 files changed, 14 insertions, 5 deletions
diff --git a/rust/src/api_helpers.rs b/rust/src/api_helpers.rs
index 020aad76..a68ed8a9 100644
--- a/rust/src/api_helpers.rs
+++ b/rust/src/api_helpers.rs
@@ -34,10 +34,7 @@ pub fn accept_editgroup(editgroup_id: Uuid, conn: &PgConnection) -> Result<Chang
.count()
.get_result(conn)?;
if count > 0 {
- bail!(
- "editgroup {} has already been accepted",
- editgroup_id.to_string()
- );
+ return Err(ErrorKind::EditgroupAlreadyAccepted(uuid2fcid(&editgroup_id)).into());
}
// for each entity type...
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index b0dff173..7bf3122b 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -216,7 +216,10 @@ fn release_row2entity(
let contribs: Vec<ReleaseContrib> = release_contrib::table
.filter(release_contrib::release_rev.eq(rev.id))
- .order((release_contrib::role.asc(), release_contrib::index_val.asc()))
+ .order((
+ release_contrib::role.asc(),
+ release_contrib::index_val.asc(),
+ ))
.get_results(conn)
.expect("fetch release refs")
.into_iter()
diff --git a/rust/src/api_wrappers.rs b/rust/src/api_wrappers.rs
index 95336d3f..403c7caf 100644
--- a/rust/src/api_wrappers.rs
+++ b/rust/src/api_wrappers.rs
@@ -308,6 +308,11 @@ impl Api for Server {
message: format!("No such editgroup: {}", id),
})
}
+ Err(Error(ErrorKind::EditgroupAlreadyAccepted(e), _)) => {
+ AcceptEditgroupResponse::BadRequest(ErrorResponse {
+ message: ErrorKind::EditgroupAlreadyAccepted(e).to_string(),
+ })
+ }
Err(e) => AcceptEditgroupResponse::GenericError(ErrorResponse {
message: e.to_string(),
}),
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 50a7d410..12ce0973 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -47,6 +47,10 @@ mod errors {
description("external identifier doesn't match required pattern")
display("external identifier doesn't match required pattern")
}
+ EditgroupAlreadyAccepted(id: String) {
+ description("editgroup was already accepted")
+ display("attempted to accept an editgroup which was already accepted: {}", id)
+ }
}
}
}