From dc9abcede17a0596ae477e6dc5e5deb282822835 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Mon, 20 Jan 2025 02:39:15 -0700 Subject: [PATCH] Clean up LemmyError::status_code (#5330) --- crates/utils/src/error.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index d9b02cf5a..49e0fa52e 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -242,14 +242,9 @@ cfg_if! { impl actix_web::error::ResponseError for LemmyError { fn status_code(&self) -> actix_web::http::StatusCode { - if self.error_type == LemmyErrorType::IncorrectLogin { - return actix_web::http::StatusCode::UNAUTHORIZED; - } - if self.error_type == LemmyErrorType::NotFound { - return actix_web::http::StatusCode::NOT_FOUND; - } - match self.inner.downcast_ref::() { - Some(diesel::result::Error::NotFound) => actix_web::http::StatusCode::NOT_FOUND, + match self.error_type { + LemmyErrorType::IncorrectLogin => actix_web::http::StatusCode::UNAUTHORIZED, + LemmyErrorType::NotFound => actix_web::http::StatusCode::NOT_FOUND, _ => actix_web::http::StatusCode::BAD_REQUEST, } }