Clean up LemmyError::status_code (#5330)

This commit is contained in:
dullbananas 2025-01-20 02:39:15 -07:00 committed by GitHub
parent 67b36c6537
commit dc9abcede1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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::<diesel::result::Error>() {
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,
}
}