Skip to main content

Error

Struct Error 

Source
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

Source

pub const fn new(kind: ErrorKind) -> Self

Source

pub fn with_ctx(self, ctx: impl Into<Cow<'static, str>>) -> Self

Source

pub fn with_source<E: Into<Box<dyn Error + Send + Sync>>>(self, e: E) -> Self

Source

pub fn io(msg: impl Into<Cow<'static, str>>) -> Self

Source

pub fn protocol(msg: impl Into<Cow<'static, str>>) -> Self

Source

pub const fn upstream(reason: UpstreamReason) -> Self

Source

pub fn middleware(msg: impl Into<Cow<'static, str>>) -> Self

Source

pub fn compile(msg: impl Into<Cow<'static, str>>) -> Self

Source

pub const fn timeout(kind: TimeoutKind) -> Self

Source

pub const fn canceled() -> Self

Source

pub const fn resource(kind: ResourceKind) -> Self

Source

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.

Source

pub const fn kind(&self) -> &ErrorKind

Source

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

Source

pub const fn kind_label(&self) -> &'static str

Source

pub const fn reason_label(&self) -> Option<&'static str>

Source

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.

Source

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 true regardless of method — the request never left the wire, so retrying a POST is safe.
  • Mid-request failures (ResetMidRequest) return true ONLY 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.

Source

pub const fn http_status(&self) -> u16

Source

pub fn source_chain(&self) -> Vec<String>

Source

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 Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<&Error> for SerializedError

Source§

fn from(e: &Error) -> Self

Converts to this type from the input type.
Source§

impl From<&Error> for TrajectoryErrorMessage

Source§

fn from(err: &Error) -> Self

Converts to this type from the input type.
Source§

impl From<AddrParseError> for Error

Source§

fn from(e: AddrParseError) -> Self

Converts to this type from the input type.
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).

Source§

fn from(d: Diagnostics) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Diagnostics

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl !UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more