MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / error_from_response

Function error_from_response

crates/openshell-driver-podman/src/client.rs:725–741  ·  view source on GitHub ↗
(status: u16, bytes: &Bytes)

Source from the content-addressed store, hash-verified

723// ── Helpers ──────────────────────────────────────────────────────────────
724
725fn error_from_response(status: u16, bytes: &Bytes) -> PodmanApiError {
726 let message = serde_json::from_slice::<Value>(bytes)
727 .ok()
728 .and_then(|v| {
729 v.get("message")
730 .or_else(|| v.get("cause"))
731 .and_then(Value::as_str)
732 .map(String::from)
733 })
734 .unwrap_or_else(|| String::from_utf8_lossy(bytes).to_string());
735
736 match status {
737 404 => PodmanApiError::NotFound(message),
738 409 => PodmanApiError::Conflict(message),
739 _ => PodmanApiError::Api { status, message },
740 }
741}
742
743/// Minimal percent-encoding for query parameter values.
744///

Callers 4

request_jsonMethod · 0.85
request_okMethod · 0.85
stop_containerMethod · 0.85
pull_imageMethod · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected