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

Function router_error_to_http

crates/openshell-supervisor-network/src/proxy.rs:2050–2063  ·  view source on GitHub ↗

Map router errors to HTTP status codes and sanitized messages. Returns generic, client-safe messages instead of verbatim internal details; the full error is recorded in the OCSF failure event by the caller.

(err: &openshell_router::RouterError)

Source from the content-addressed store, hash-verified

2048/// Returns generic, client-safe messages instead of verbatim internal details;
2049/// the full error is recorded in the OCSF failure event by the caller.
2050fn router_error_to_http(err: &openshell_router::RouterError) -> (u16, String) {
2051 use openshell_router::RouterError;
2052 match err {
2053 RouterError::RouteNotFound(_) => (400, "no inference route configured".to_string()),
2054 RouterError::NoCompatibleRoute(_) => {
2055 (400, "no compatible inference route available".to_string())
2056 }
2057 RouterError::Unauthorized(_) => (401, "unauthorized".to_string()),
2058 RouterError::UpstreamUnavailable(_) => (503, "inference service unavailable".to_string()),
2059 RouterError::UpstreamProtocol(_) | RouterError::Internal(_) => {
2060 (502, "inference service error".to_string())
2061 }
2062 }
2063}
2064
2065fn sanitize_inference_response_headers(headers: Vec<(String, String)>) -> Vec<(String, String)> {
2066 headers

Calls

no outgoing calls