mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2026-01-26 13:35:13 +03:00
refactor(middlewares): move MiddlewareError from crate::utility to crate::middlewares
This commit is contained in:
19
src/middlewares/error.rs
Normal file
19
src/middlewares/error.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Display;
|
||||
use std::fmt::Write;
|
||||
|
||||
/// Server response to errors within Middleware.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct MiddlewareError<T: Display> {
|
||||
code: T,
|
||||
message: String,
|
||||
}
|
||||
|
||||
impl<T: Display + Serialize> MiddlewareError<T> {
|
||||
pub fn new(code: T) -> Self {
|
||||
let mut message = String::new();
|
||||
write!(&mut message, "{}", code).unwrap();
|
||||
|
||||
Self { code, message }
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,4 @@
|
||||
pub mod error;
|
||||
|
||||
pub mod authorization;
|
||||
pub mod content_type;
|
||||
|
||||
Reference in New Issue
Block a user