Skip to content

calternal_api::http_failure

Typed HTTP failures shared by client surfaces (#835, DESIGN §41). Preserve the existing error envelope and Retry-After value. This adds client metadata without changing server responses or requiring problem+json.

Source: crates/calternal-api/src/http_failure.rs

pub struct HttpFailure

An HTTP status and its safe server error object. Unknown codes and detail fields survive unchanged so an older client can classify a newer response.

Fields

  • pub status: u16
  • pub error: Value
  • pub payload: Value: Preserve typed non-envelope failures and any extra root fields (#835).
  • pub retry_after: Option<String>

Implements: Debug, Clone, Deserialize, Serialize, std::fmt::Display, std::error::Error

pub fn from_parts(status: u16, body: &[u8], retry_after: Option<String>) -> Self

Parse a bounded response body; malformed gateway HTML is never echoed. An absent error object keeps the legacy status-only human message.

pub fn with_display_text(mut self, text: String) -> Self

Keep a client’s existing human diagnostic while typed fields stay intact (#835).

pub fn with_status_label(self, status: &str) -> Self

Keep a transport’s canonical status wording without duplicating its formatter (#835).

pub fn message(&self) -> Option<&str>

Return the server’s error message while keeping code/details as data.

Source: crates/calternal-api/src/http_failure.rs:14

pub const MAX_HTTP_ERROR_BODY_BYTES: usize

Share the client failure-body budget across HTTP library versions (#835).

Source: crates/calternal-api/src/http_failure.rs:9