pub struct Error {
pub kind: ErrorKind,
pub ctx: Option<Cow<'static, str>>,
pub source: Option<Box<dyn Error + Send + Sync>>,
}Fields§
§kind: ErrorKind§ctx: Option<Cow<'static, str>>§source: Option<Box<dyn Error + Send + Sync>>Implementations§
Source§impl Error
impl Error
pub const fn new(kind: ErrorKind) -> Self
pub fn with_ctx(self, ctx: impl Into<Cow<'static, str>>) -> Self
pub fn with_source<E: Into<Box<dyn Error + Send + Sync>>>(self, e: E) -> Self
pub fn io(msg: impl Into<Cow<'static, str>>) -> Self
pub fn protocol(msg: impl Into<Cow<'static, str>>) -> Self
pub const fn upstream(reason: UpstreamReason) -> Self
pub fn middleware(msg: impl Into<Cow<'static, str>>) -> Self
pub fn compile(msg: impl Into<Cow<'static, str>>) -> Self
pub const fn timeout(kind: TimeoutKind) -> Self
pub const fn canceled() -> Self
pub const fn resource(kind: ResourceKind) -> Self
Sourcepub fn internal(msg: impl Into<Cow<'static, str>>) -> Self
pub fn internal(msg: impl Into<Cow<'static, str>>) -> Self
Build an ErrorKind::Internal carrier for a detected invariant
violation.
Reserved for invariant breaks. The error class signals that
the code has reached a state the type system or the lower-pass
invariants were supposed to make unreachable — examples in this
codebase are l4_forward receiving an unexpected L4Conn
variant, the executor finding the dispatch table missing from
ConnContext.user, or a response builder rejecting bytes we
validated upstream. Runtime user-data failures
(std::io::Error, WASM trap, hyper-build mismatch on operator-
controlled bytes) belong on Error::middleware / Error::io /
Error::protocol instead.
In debug / test builds the constructor debug_assert!s false so
the panic surfaces locally with the message context — invariant
breaks are bugs that deserve to be found at dev time, not
silently 500ed in production. Release builds keep the cheap
Error construction path.
pub const fn kind(&self) -> &ErrorKind
pub fn ctx(&self) -> Option<&str>
pub const fn kind_label(&self) -> &'static str
pub const fn reason_label(&self) -> Option<&'static str>
Sourcepub const fn is_retryable(&self) -> bool
pub const fn is_retryable(&self) -> bool
Method-agnostic retry eligibility. Returns true for the
pre-connect failures (request never left the wire), plus the
hyper-pool race cases (ResetOnIdlePickup, Refused,
Gone) and DNS / unreachable / connect-timeout — all of
which are safe to retry regardless of HTTP method idempotency.
Mid-request failures (ResetMidRequest) need a method check
before retrying so we don’t double-deliver a POST body. Use
Self::is_retryable_in for that path; this method exists
for back-compat with callers that already pre-gate on method
idempotency.
Sourcepub fn is_retryable_in(&self, method: &Method) -> bool
pub fn is_retryable_in(&self, method: &Method) -> bool
Method-aware retry eligibility, per spec/crates/engine.md
§ Error classification:
- Pre-connect failures (TCP connect, TLS handshake, DNS,
connection-pool exhaustion, hyper-pool idle-pickup race)
return
trueregardless of method — the request never left the wire, so retrying a POST is safe. - Mid-request failures (
ResetMidRequest) returntrueONLY for idempotent methods (GET / HEAD / PUT / DELETE / OPTIONS, per RFC 9110 § 9.2.2). Retrying a non-idempotent POST mid-request risks double-delivery. - All other error kinds return
false.
Method::TRACE is treated as non-idempotent in this table
— RFC 9110 lists it as idempotent but middleboxes routinely
rewrite it, so retrying is rarely the right move at proxy
scope.
pub const fn http_status(&self) -> u16
pub fn source_chain(&self) -> Vec<String>
Sourcepub fn tracing(&self) -> ErrorTracing<'_>
pub fn tracing(&self) -> ErrorTracing<'_>
Display adapter that renders the error in a richer one-line
form suitable for tracing::error!(error = %e.tracing(), …).
Layout:
<Display> reason=<reason?> chain=[<src> / <src> / …]Drop-in replacement for error = %e. kind is already
embedded in the Display impl (<kind>{ctx}); reason and
chain add the structured fields that operator post-mortems
otherwise lose. Released by to_string(); no extra allocations
at construction time.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<&Error> for SerializedError
impl From<&Error> for SerializedError
Source§impl From<&Error> for TrajectoryErrorMessage
impl From<&Error> for TrajectoryErrorMessage
Source§impl From<AddrParseError> for Error
impl From<AddrParseError> for Error
Source§fn from(e: AddrParseError) -> Self
fn from(e: AddrParseError) -> Self
Source§impl From<Diagnostics> for Error
Collapse the accumulated diagnostics into a single
ErrorKind::Compile Error whose context carries every entry’s
to_string(), separated by \n. Used at the boundary into APIs
whose error channel is a single Error (e.g. the existing
compile() facade, the management-RPC wire payload).
impl From<Diagnostics> for Error
Collapse the accumulated diagnostics into a single
ErrorKind::Compile Error whose context carries every entry’s
to_string(), separated by \n. Used at the boundary into APIs
whose error channel is a single Error (e.g. the existing
compile() facade, the management-RPC wire payload).