Skip to main content

format_http_error

Function format_http_error 

Source
pub fn format_http_error(e: &HttpError, prefix: &str) -> String
Expand description

Format an modkit_http::HttpError into a human-readable message with a context prefix.

The prefix identifies the caller context (e.g. "JWKS", "OAuth2 token") and is prepended to every message so log output is immediately attributable.

This function is the single place that handles the exhaustive (plus #[non_exhaustive] catch-all) match on HttpError, shared by JWKS key fetching, OAuth2 token acquisition, and any future HTTP-based provider.

§Security

HttpStatus errors include only the status code — the response body is deliberately excluded to prevent server-side diagnostics from leaking into logs or error messages. The catch-all arm falls back to the variant’s Display impl so that new variants are not silently hidden.