feat: 添加PAYMENT_MAINTENANCE_MODE维护模式 + ServiceUnavailable错误
This commit is contained in:
@@ -53,6 +53,7 @@ pub enum AppError {
|
||||
Internal(String),
|
||||
Database(String),
|
||||
TooManyRequests(String),
|
||||
ServiceUnavailable(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for AppError {
|
||||
@@ -65,6 +66,7 @@ impl fmt::Display for AppError {
|
||||
AppError::Internal(msg) => write!(f, "{}", msg),
|
||||
AppError::Database(msg) => write!(f, "{}", msg),
|
||||
AppError::TooManyRequests(msg) => write!(f, "{}", msg),
|
||||
AppError::ServiceUnavailable(msg) => write!(f, "{}", msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,6 +80,7 @@ impl ResponseError for AppError {
|
||||
AppError::BadRequest(_) => StatusCode::BAD_REQUEST,
|
||||
AppError::Internal(_) | AppError::Database(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
AppError::TooManyRequests(_) => StatusCode::TOO_MANY_REQUESTS,
|
||||
AppError::ServiceUnavailable(_) => StatusCode::SERVICE_UNAVAILABLE,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +172,7 @@ impl ResponseError for AppError {
|
||||
AppError::BadRequest(_) => "请求无效",
|
||||
AppError::Internal(_) | AppError::Database(_) => "服务器错误",
|
||||
AppError::TooManyRequests(_) => "请求过于频繁",
|
||||
AppError::ServiceUnavailable(_) => "服务暂不可用",
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user