mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 17:57:47 +03:00
20 lines
459 B
Rust
20 lines
459 B
Rust
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 }
|
|
}
|
|
}
|