修正 Raw 图片尺寸校验错误语义
尺寸校验失败改用请求参数无效语义 补充错误文案回归测试
This commit is contained in:
@@ -100,7 +100,7 @@ pub async fn create_vector_engine_raw_image_edit(
|
|||||||
failure_context: &str,
|
failure_context: &str,
|
||||||
) -> Result<GeneratedImages, PlatformImageError> {
|
) -> Result<GeneratedImages, PlatformImageError> {
|
||||||
validate_raw_image_edit_dimensions(options.width, options.height)
|
validate_raw_image_edit_dimensions(options.width, options.height)
|
||||||
.map_err(|error| invalid_request(failure_context, error.to_string()))?;
|
.map_err(|error| invalid_input(failure_context, error.to_string()))?;
|
||||||
let url = vector_engine_images_edit_url(settings);
|
let url = vector_engine_images_edit_url(settings);
|
||||||
let started_at = Instant::now();
|
let started_at = Instant::now();
|
||||||
let prompt_chars = Some(prompt.chars().count());
|
let prompt_chars = Some(prompt.chars().count());
|
||||||
@@ -347,6 +347,13 @@ fn invalid_request(context: &str, message: String) -> PlatformImageError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn invalid_input(context: &str, message: String) -> PlatformImageError {
|
||||||
|
PlatformImageError::InvalidRequest {
|
||||||
|
provider: VECTOR_ENGINE_PROVIDER,
|
||||||
|
message: format!("{context}:请求参数无效:{message}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn invalid_config(message: String) -> PlatformImageError {
|
fn invalid_config(message: String) -> PlatformImageError {
|
||||||
PlatformImageError::InvalidConfig {
|
PlatformImageError::InvalidConfig {
|
||||||
provider: VECTOR_ENGINE_PROVIDER,
|
provider: VECTOR_ENGINE_PROVIDER,
|
||||||
@@ -566,4 +573,11 @@ mod tests {
|
|||||||
Err(RawImageEditDimensionError::PixelCount)
|
Err(RawImageEditDimensionError::PixelCount)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn dimension_validation_error_identifies_client_input() {
|
||||||
|
let error = invalid_input("raw_image_edit", "尺寸无效".to_string());
|
||||||
|
|
||||||
|
assert_eq!(error.to_string(), "raw_image_edit:请求参数无效:尺寸无效");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user