minor fixes

This commit is contained in:
Pascal Seitz
2022-04-20 12:38:11 +08:00
parent 6614a2cba0
commit 2805291400
2 changed files with 10 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ impl AggregationResults {
} else {
// Validation is be done during request parsing, so we can't reach this state.
Err(TantivyError::InternalError(format!(
"Can't find aggregation in {}",
"Can't find aggregation {:?} in sub_aggregations",
name
)))
}
@@ -124,9 +124,9 @@ impl AggregationResult {
agg_property: &str,
) -> crate::Result<Option<f64>> {
match self {
AggregationResult::BucketResult(_bucket) => Err(TantivyError::InvalidArgument(
"bucket aggregation not supported to retrieve value, only metrics aggregations \
are supported."
AggregationResult::BucketResult(_bucket) => Err(TantivyError::InternalError(
"Tried to retrieve value from bucket aggregation. This is not supported and \
should not happen during collection, but should be catched during validation"
.to_string(),
)),
AggregationResult::MetricResult(metric) => metric.get_value(agg_property),

View File

@@ -131,4 +131,10 @@ fn custom_order_serde_test() {
let order_deser = serde_json::from_str(&order_str).unwrap();
assert_eq!(order, order_deser);
let order_deser: serde_json::Result<CustomOrder> = serde_json::from_str(&"{}");
assert!(order_deser.is_err());
let order_deser: serde_json::Result<CustomOrder> = serde_json::from_str(&"[]");
assert!(order_deser.is_err());
}