server_common/error/
config.rs1use axum::{
2 http::StatusCode,
3 response::{IntoResponse, Response},
4};
5
6#[derive(Debug)]
8pub enum ConfigError {
9 DatabaseError,
10 RedisError,
11 PathError,
12 NotExistError,
13}
14
15impl IntoResponse for ConfigError {
17 fn into_response(self) -> Response {
18 let (status, error_message) = match self {
19 ConfigError::DatabaseError => {
20 (StatusCode::INTERNAL_SERVER_ERROR, "database config error")
21 }
22 ConfigError::RedisError => (StatusCode::INTERNAL_SERVER_ERROR, "redis config error"),
23 ConfigError::PathError => (StatusCode::INTERNAL_SERVER_ERROR, "config path error"),
24 ConfigError::NotExistError => {
25 (StatusCode::INTERNAL_SERVER_ERROR, "config not exist error")
26 }
27 };
28
29 (status, error_message).into_response()
30 }
31}