Skip to main content

trust_tasks_https/
error.rs

1//! Shared error type used by both the client and server.
2//!
3//! Most error responses *that the framework defines* are themselves
4//! Trust Task documents (`trust-task-error`); the consumer-side
5//! pipeline assembles them via [`trust_tasks_rs::TransportHandler::reject`].
6//! [`TransportError`] is reserved for failures that don't fit the
7//! framework's payload model — connectivity issues, malformed JSON
8//! arriving at the transport layer, etc.
9
10use thiserror::Error;
11
12/// Transport-level failures: I/O, broken HTTP framing, body that doesn't
13/// even parse as JSON. Distinct from `trust-task-error` documents,
14/// which a well-behaved peer returns inside an HTTP response body and
15/// which this crate surfaces as typed values via [`crate::ClientError`].
16#[derive(Debug, Error)]
17pub enum TransportError {
18    /// The request or response body could not be deserialised as JSON.
19    #[error("transport body is not valid JSON: {0}")]
20    InvalidJson(#[from] serde_json::Error),
21
22    /// The transport-authenticated identity was required but unavailable
23    /// (no bearer header, no recognised token).
24    #[error("transport authentication required but not provided")]
25    AuthRequired,
26
27    /// Any other transport-level failure surfaced by the underlying
28    /// implementation (axum / reqwest / tokio).
29    #[error("transport failure: {0}")]
30    Other(String),
31}