From 9ccad00474ce8881dab8515f691fcb793d95fd27 Mon Sep 17 00:00:00 2001 From: John Spray Date: Tue, 5 Sep 2023 09:43:28 +0100 Subject: [PATCH] libs: add ApiError::ShuttingDown --- libs/utils/src/http/error.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/utils/src/http/error.rs b/libs/utils/src/http/error.rs index 527e486fd0..dd54cd6ecd 100644 --- a/libs/utils/src/http/error.rs +++ b/libs/utils/src/http/error.rs @@ -24,6 +24,9 @@ pub enum ApiError { #[error("Precondition failed: {0}")] PreconditionFailed(Box), + #[error("Shutting down")] + ShuttingDown, + #[error(transparent)] InternalServerError(anyhow::Error), } @@ -52,6 +55,10 @@ impl ApiError { self.to_string(), StatusCode::PRECONDITION_FAILED, ), + ApiError::ShuttingDown => HttpErrorBody::response_from_msg_and_status( + "Shutting down".to_string(), + StatusCode::SERVICE_UNAVAILABLE, + ), ApiError::InternalServerError(err) => HttpErrorBody::response_from_msg_and_status( err.to_string(), StatusCode::INTERNAL_SERVER_ERROR,