Added error 501

This commit is contained in:
J-onasJones 2024-01-01 17:18:08 +01:00
parent 3c1d88bd42
commit 5c7c572641
2 changed files with 9 additions and 3 deletions

View file

@ -26,3 +26,7 @@ impl warp::reject::Reject for UnauthorizedError {}
pub struct ForbiddenError;
impl warp::reject::Reject for ForbiddenError {}
#[derive(Debug)]
pub struct NotImplementedError;
impl warp::reject::Reject for NotImplementedError {}

View file

@ -5,7 +5,7 @@ use reqwest::StatusCode;
use warp::Filter;
use warp::reply::Reply;
use crate::error_responses::{ErrorMessage, InternalServerError, BadRequestError, NotFoundError};
use crate::error_responses::{ErrorMessage, InternalServerError, BadRequestError, NotFoundError, NotImplementedError};
use crate::v1::get_v1_routes;
use crate::{Logger, parse_ip};
@ -32,6 +32,8 @@ pub async fn serve() {
(StatusCode::BAD_REQUEST, "Bad Request")
} else if err.is_not_found() || err.find::<NotFoundError>().is_some() {
(StatusCode::NOT_FOUND, "Not Found")
} else if err.find::<NotImplementedError>().is_some() {
(StatusCode::NOT_IMPLEMENTED, "Not Implemented")
} else {
(StatusCode::INTERNAL_SERVER_ERROR, "Unhandled Rejection") // Default case
};