mirror of
https://github.com/JonasunderscoreJones/jonas_jones-api.git
synced 2025-10-23 09:09:18 +02:00
Implemented new Error handling system
New Error Handling System with custom errors and JSON Error responses
This commit is contained in:
parent
4357786edc
commit
83ba68a8b7
3 changed files with 53 additions and 1 deletions
28
src/error_responses.rs
Normal file
28
src/error_responses.rs
Normal 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 {}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue