Fault-tolerant delivery system
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user