feat: send puzzle result subscribe messages
This commit is contained in:
@@ -2,6 +2,7 @@ use axum::http::{HeaderValue, StatusCode};
|
||||
use platform_auth::{AuthPlatformErrorKind, WechatProviderError};
|
||||
use platform_llm::{LlmError, LlmErrorKind};
|
||||
use platform_oss::{OssError, OssErrorKind};
|
||||
use platform_wechat::{WechatError, WechatErrorKind};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::http_error::AppError;
|
||||
@@ -68,6 +69,17 @@ pub fn map_wechat_provider_error(error: WechatProviderError) -> AppError {
|
||||
AppError::from_status(status).with_message(error.to_string())
|
||||
}
|
||||
|
||||
pub fn map_wechat_error(error: WechatError) -> AppError {
|
||||
let status = match error.kind() {
|
||||
WechatErrorKind::InvalidConfig => StatusCode::SERVICE_UNAVAILABLE,
|
||||
WechatErrorKind::RequestFailed
|
||||
| WechatErrorKind::DeserializeFailed
|
||||
| WechatErrorKind::Upstream => StatusCode::BAD_GATEWAY,
|
||||
};
|
||||
|
||||
AppError::from_status(status).with_message(error.to_string())
|
||||
}
|
||||
|
||||
pub fn attach_retry_after(error: AppError, retry_after_seconds: u64) -> AppError {
|
||||
match HeaderValue::from_str(&retry_after_seconds.to_string()) {
|
||||
Ok(value) => error.with_header("retry-after", value),
|
||||
|
||||
Reference in New Issue
Block a user