Refactor errors

This commit is contained in:
2026-03-12 23:04:59 -07:00
parent 60483dd53d
commit 26a428dedc
17 changed files with 192 additions and 161 deletions

View File

@@ -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;
}
})
}