Skip to content

Commit c0ba176

Browse files
committed
Add error context with method name
This will make it much more obvious in errors which proxy operation we're doing. Right now we can get e.g. a bare error message like "Deserializing value: Expected sequence, not null" e.g. Signed-off-by: Colin Walters <[email protected]>
1 parent f291085 commit c0ba176

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/imageproxy.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@ impl ImageProxy {
304304
let mut childwait = self.childwait.lock().await;
305305
tokio::select! {
306306
r = req => {
307-
Ok(r?)
307+
Ok(r.with_context(|| format!("Failed to invoke skopeo proxy method {method}"))?)
308308
}
309309
r = childwait.as_mut() => {
310310
let r = r??;
311311
let stderr = String::from_utf8_lossy(&r.stderr);
312-
return Err(anyhow::anyhow!("proxy unexpectedly exited during request method {}: {}\n{}", method, r.status, stderr))
312+
return Err(anyhow::anyhow!("skopeo proxy unexpectedly exited during request method {}: {}\n{}", method, r.status, stderr))
313313
}
314314
}
315315
}
@@ -380,7 +380,8 @@ impl ImageProxy {
380380
img: &OpenedImage,
381381
) -> Result<(String, oci_spec::image::ImageManifest)> {
382382
let (digest, raw) = self.fetch_manifest_raw_oci(img).await?;
383-
let manifest = serde_json::from_slice(&raw)?;
383+
let manifest =
384+
serde_json::from_slice(&raw).context("Deserializing manifest from skopeo")?;
384385
Ok((digest, manifest))
385386
}
386387

@@ -400,7 +401,7 @@ impl ImageProxy {
400401
img: &OpenedImage,
401402
) -> Result<oci_spec::image::ImageConfiguration> {
402403
let raw = self.fetch_config_raw(img).await?;
403-
Ok(serde_json::from_slice(&raw)?)
404+
Ok(serde_json::from_slice(&raw).context("Deserializing config from skopeo")?)
404405
}
405406

406407
/// Fetch a blob identified by e.g. `sha256:<digest>`.

0 commit comments

Comments
 (0)