ValidationError was not correctly handled

This commit is contained in:
Olivier Dehaene 2022-10-11 16:53:40 +02:00
parent 4c693e6524
commit e86ecbac63
1 changed files with 5 additions and 3 deletions

View File

@ -69,13 +69,15 @@ async fn generate(
) -> poem::Result<Json<serde_json::Value>> {
let start = Instant::now();
let (input_length, validated_request) = validation
let (input_length, validated_request) = match validation
.validate(GenerateRequest {
inputs: req.inputs.clone(),
parameters: req.parameters.clone(),
})
.await
.unwrap();
.await {
Ok(result) => result,
Err(_) => return Err(poem::Error::from_status(StatusCode::INTERNAL_SERVER_ERROR))
};
let output = infer.infer(input_length, validated_request).await;