Refactor errors
This commit is contained in:
@@ -199,30 +199,14 @@ impl PileValue {
|
||||
Value::String(format!("<Blob ({mime}, {} bytes)>", bytes.len()))
|
||||
}
|
||||
|
||||
#[expect(clippy::expect_used)]
|
||||
Self::Array(_) | Self::ListExtractor(_) => {
|
||||
let e = self.list_extractor();
|
||||
let len = e.len().await?;
|
||||
let mut arr = Vec::new();
|
||||
for i in 0..len {
|
||||
let v = e.get(i).await?.expect("item must be present");
|
||||
arr.push(Box::pin(v.to_json()).await?);
|
||||
}
|
||||
Value::Array(arr)
|
||||
return e.to_json().await;
|
||||
}
|
||||
|
||||
Self::ObjectExtractor(_) | Self::Item(_) => {
|
||||
let e = self.object_extractor();
|
||||
let keys = e.fields().await?;
|
||||
let mut map = Map::new();
|
||||
for k in &keys {
|
||||
let v = match e.field(k, None).await? {
|
||||
Some(x) => x,
|
||||
None => continue,
|
||||
};
|
||||
map.insert(k.to_string(), Box::pin(v.to_json()).await?);
|
||||
}
|
||||
Value::Object(map)
|
||||
return e.to_json().await;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user