Tweak status codes
Some checks failed
CI / Clippy (push) Successful in 1m2s
CI / Typos (push) Failing after 1m10s
Docker / build-and-push (push) Failing after 2m21s
CI / Build and test (all features) (push) Successful in 3m27s
CI / Build and test (push) Successful in 6m7s

This commit is contained in:
2026-04-03 12:35:01 -07:00
parent 0281a33f86
commit 251d130987
2 changed files with 19 additions and 4 deletions

View File

@@ -101,17 +101,24 @@ pub async fn get_extract(
let mut value = None; let mut value = None;
for path in &paths { for path in &paths {
match item.query(&extract_state, path).await { match item.query(&extract_state, path).await {
Ok(Some(PileValue::Null)) | Ok(None) => continue, Ok(None) => continue,
Ok(Some(PileValue::Null)) => {
value = Some(PileValue::Null);
continue;
}
Ok(Some(v)) => { Ok(Some(v)) => {
value = Some(v); value = Some(v);
break; break;
} }
Err(e) => return (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")).into_response(), Err(e) => return (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")).into_response(),
} }
} }
let Some(value) = value else { let Some(value) = value else {
return StatusCode::NOT_FOUND.into_response(); return (StatusCode::BAD_REQUEST, "no value").into_response();
}; };
debug!( debug!(
@@ -177,6 +184,7 @@ pub async fn get_extract(
Json(json), Json(json),
) )
.into_response(), .into_response(),
Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")).into_response(), Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")).into_response(),
}, },
} }

View File

@@ -84,17 +84,24 @@ pub async fn schema_field(
let mut value = None; let mut value = None;
for path in paths { for path in paths {
match item.query(&extract_state, path).await { match item.query(&extract_state, path).await {
Ok(Some(PileValue::Null)) | Ok(None) => continue, Ok(None) => continue,
Ok(Some(PileValue::Null)) => {
value = Some(PileValue::Null);
continue;
}
Ok(Some(v)) => { Ok(Some(v)) => {
value = Some(v); value = Some(v);
break; break;
} }
Err(e) => return (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")).into_response(), Err(e) => return (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:?}")).into_response(),
} }
} }
let Some(value) = value else { let Some(value) = value else {
return StatusCode::NOT_FOUND.into_response(); return (StatusCode::BAD_REQUEST, "no value").into_response();
}; };
debug!( debug!(