Fault-tolerant delivery system

This commit is contained in:
Alphonse Paix
2025-09-04 02:54:49 +02:00
parent d47fba5cc9
commit 3057fdc927
31 changed files with 872 additions and 116 deletions

View File

@@ -22,7 +22,9 @@ pub enum AdminError {
#[error("Updating password failed.")]
ChangePassword,
#[error("Could not publish newsletter.")]
Publish,
Publish(#[source] anyhow::Error),
#[error("The idempotency key was invalid.")]
Idempotency(String),
}
impl std::fmt::Debug for AdminError {
@@ -50,7 +52,10 @@ impl IntoResponse for AdminError {
.into_response(),
AdminError::NotAuthenticated => Redirect::to("/login").into_response(),
AdminError::ChangePassword => Redirect::to("/admin/password").into_response(),
AdminError::Publish => Redirect::to("/admin/newsletters").into_response(),
AdminError::Publish(_) => Redirect::to("/admin/newsletters").into_response(),
AdminError::Idempotency(e) => {
(StatusCode::BAD_REQUEST, Json(ErrorResponse { message: e })).into_response()
}
}
}
}