return accurate http status codes for dashboard client errors

This commit is contained in:
damocles 2026-06-22 13:57:27 +02:00 committed by mara
commit 5dc1b3933a
7 changed files with 63 additions and 22 deletions

View file

@ -10,7 +10,7 @@ use axum::{
response::{IntoResponse, Response},
};
use super::{AppState, error_response};
use super::{AppState, error_response, problem_response};
pub(super) async fn api_reminders(State(state): State<AppState>) -> Response {
match state.coord.broker.list_pending_reminders() {
@ -24,7 +24,10 @@ pub(super) async fn post_cancel_reminder(
AxumPath(id): AxumPath<i64>,
) -> Response {
match state.coord.broker.cancel_reminder(id) {
Ok(0) => error_response(&format!("reminder {id} not pending (already delivered?)")),
Ok(0) => problem_response(
StatusCode::NOT_FOUND,
&format!("reminder {id} not pending (already delivered?)"),
),
Ok(_) => {
tracing::info!(%id, "operator cancelled reminder");
state.coord.emit_reminders_snapshot();
@ -44,7 +47,10 @@ pub(super) async fn post_retry_reminder(
AxumPath(id): AxumPath<i64>,
) -> Response {
match state.coord.broker.reset_reminder_failure(id) {
Ok(0) => error_response(&format!("reminder {id} not pending (already delivered?)")),
Ok(0) => problem_response(
StatusCode::NOT_FOUND,
&format!("reminder {id} not pending (already delivered?)"),
),
Ok(_) => {
tracing::info!(%id, "operator reset reminder failure for retry");
state.coord.emit_reminders_snapshot();