补充 Raw 图片客户端错误上下文
为 HTTP 客户端构造失败统一保留操作上下文 补充配置错误文案回归测试
This commit is contained in:
@@ -152,7 +152,7 @@ pub async fn create_vector_engine_raw_image_edit(
|
||||
.timeout(Duration::from_millis(request_timeout_ms))
|
||||
.http1_only()
|
||||
.build()
|
||||
.map_err(|error| invalid_config(error.to_string()))?;
|
||||
.map_err(|error| invalid_config(failure_context, error.to_string()))?;
|
||||
let response = client
|
||||
.post(url.as_str())
|
||||
.bearer_auth(settings.api_key.as_str())
|
||||
@@ -354,10 +354,10 @@ fn invalid_input(context: &str, message: String) -> PlatformImageError {
|
||||
}
|
||||
}
|
||||
|
||||
fn invalid_config(message: String) -> PlatformImageError {
|
||||
fn invalid_config(context: &str, message: String) -> PlatformImageError {
|
||||
PlatformImageError::InvalidConfig {
|
||||
provider: VECTOR_ENGINE_PROVIDER,
|
||||
message,
|
||||
message: format!("{context}:构造请求客户端失败:{message}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -580,4 +580,14 @@ mod tests {
|
||||
|
||||
assert_eq!(error.to_string(), "raw_image_edit:请求参数无效:尺寸无效");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_config_error_keeps_operation_context() {
|
||||
let error = invalid_config("raw_image_edit", "builder failed".to_string());
|
||||
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"raw_image_edit:构造请求客户端失败:builder failed"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user