mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
34 lines
825 B
Rust
34 lines
825 B
Rust
use http::status::StatusCode;
|
|
use std::fmt::{self, Display, Formatter};
|
|
|
|
#[derive(Default, thiserror::Error, Debug, Clone, PartialEq)]
|
|
pub struct AdminError {
|
|
pub code: String,
|
|
pub message: String,
|
|
pub status_code: StatusCode,
|
|
}
|
|
|
|
impl Display for AdminError {
|
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
|
write!(f, "{}", self.message)
|
|
}
|
|
}
|
|
|
|
impl AdminError {
|
|
pub fn new(code: &str, message: &str, status_code: StatusCode) -> Self {
|
|
Self {
|
|
code: code.to_string(),
|
|
message: message.to_string(),
|
|
status_code,
|
|
}
|
|
}
|
|
|
|
pub fn msg(message: &str) -> Self {
|
|
Self {
|
|
code: "InternalError".to_string(),
|
|
message: message.to_string(),
|
|
status_code: StatusCode::INTERNAL_SERVER_ERROR,
|
|
}
|
|
}
|
|
}
|