From 968a28c6e68e35e127ec3dd20ed2a8eeb8b30cc0 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2026 05:00:06 +0100 Subject: unify API error responses --- src/remake/api.rs | 13 +------------ src/remake/quarantine.rs | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) (limited to 'src/remake') diff --git a/src/remake/api.rs b/src/remake/api.rs index 24fb7e8..515468d 100644 --- a/src/remake/api.rs +++ b/src/remake/api.rs @@ -72,6 +72,7 @@ use super::records::{ Retention, Vote, }; use super::{Host, kind, vote}; +use crate::api::error_response; use crate::document::store::StoreError; use crate::force::Force; @@ -281,18 +282,6 @@ enum StartError { Store(#[from] StoreError), } -pub(super) fn error_response( - status: StatusCode, - message: impl Into, - details: Option, -) -> Response { - let mut body = json!({ "error": message.into() }); - if let (Some(JsonValue::Object(extra)), Some(object)) = (details, body.as_object_mut()) { - object.extend(extra); - } - (status, Json(body)).into_response() -} - fn grace(host: &H) -> u64 { host.dormant_after().as_millis() as u64 } diff --git a/src/remake/quarantine.rs b/src/remake/quarantine.rs index e7ef136..b5166c9 100644 --- a/src/remake/quarantine.rs +++ b/src/remake/quarantine.rs @@ -27,10 +27,10 @@ use tracing::{info, warn}; use uuid::Uuid; use super::Host; -use super::api::error_response; use super::delta; use super::kind::Translator; use super::local::Quarantined; +use crate::api::error_response; use crate::document::replica::Epoch; use crate::document::store; -- cgit v1.3.1