mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-20 13:58:20 +00:00
Clean up LemmyError::status_code (#5330)
This commit is contained in:
parent
67b36c6537
commit
dc9abcede1
1 changed files with 3 additions and 8 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue