Implemented new Error handling system

New Error Handling System with custom errors and JSON Error responses
This commit is contained in:
Jonas_Jones 2023-12-15 03:30:43 +01:00
parent 4357786edc
commit 83ba68a8b7
3 changed files with 53 additions and 1 deletions

28
src/error_responses.rs Normal file
View file

@ -0,0 +1,28 @@
use serde::Serialize;
#[derive(Serialize)]
pub struct ErrorMessage {
pub(crate) code: u16,
pub(crate) message: String,
}
#[derive(Debug)]
pub struct InternalServerError;
impl warp::reject::Reject for InternalServerError {}
#[derive(Debug)]
pub struct BadRequestError;
impl warp::reject::Reject for BadRequestError {}
#[derive(Debug)]
pub struct NotFoundError;
impl warp::reject::Reject for NotFoundError {}
#[derive(Debug)]
pub struct UnauthorizedError;
impl warp::reject::Reject for UnauthorizedError {}
#[derive(Debug)]
pub struct ForbiddenError;
impl warp::reject::Reject for ForbiddenError {}