Skip to main content

Fail

Enum Fail 

Source
pub enum Fail<D, L: LaneProfile = AllLanes> {
    Rejected(D),
    Denied(L::Denied),
    Transient(L::Transient),
    Fatal(L::Fatal),
}
Expand description

The generic view over a domain rejection D, before retries have run.

Display discipline: Display’s Rejected arm keeps its rejected: {d} prefix for logs, but no boundary may build a user-facing message from to_string() — a rejection’s message may embed caller-supplied input. Use as_rejected and Rejection::code instead: record_fail keys error.code off the code, never the message, and a GraphQL boundary should do the same for its error extension.

Variants§

§

Rejected(D)

§

Denied(L::Denied)

§

Transient(L::Transient)

§

Fatal(L::Fatal)

Implementations§

Source§

impl<D, L: LaneProfile<Denied = Denied>> Fail<D, L>

Source

pub fn as_denied(&self) -> Option<&Denied>

Source§

impl<D, L: LaneProfile<Transient = Transient>> Fail<D, L>

Source

pub fn as_transient(&self) -> Option<&Transient>

Source

pub fn is_congestion(&self) -> bool

Source

pub fn is_contention(&self) -> bool

See [TransientKind::is_contention].

Source§

impl<D, L: LaneProfile<Fatal = Fatal>> Fail<D, L>

Source

pub fn as_fatal(&self) -> Option<&Fatal>

Source§

impl<D, L: LaneProfile> Fail<D, L>

Source

pub fn lane(&self) -> Lane

Source

pub fn widen<P: Lift<D>, M: LaneProfile>(self) -> Fail<P, M>
where L::Denied: Into<M::Denied>, L::Transient: Into<M::Transient>, L::Fatal: Into<M::Fatal>, P::Unmapped: UnmappedInto<M::Fatal>,

Widen the rejection and the lane profile without changing any classification. The value-level form of [WidenResult::widen], with the same single rule: P: Lift<D> is satisfied by a total From<D> (through errlanes’ blanket, Unmapped = Infallible) and by a partial #[lift(Source, unhandled = fatal)] mapping (Unmapped = Source), whose unmapped cases demote to Fatal(Invariant) with the rejection as their source — which is why a partial mapping requires the destination to admit Fatal. The strict/partial choice is declared once on the destination enum; the call site does not repeat it.

Source

pub fn widen_with<P, M: LaneProfile<Fatal = Fatal>>( self, f: impl FnOnce(D) -> Result<P, Fatal>, ) -> Fail<P, M>
where L::Denied: Into<M::Denied>, L::Transient: Into<M::Transient>, L::Fatal: Into<M::Fatal>,

Source

pub fn map_rejected<D2>(self, f: impl FnOnce(D) -> D2) -> Fail<D2, L>

Source

pub fn rejected(self) -> Result<D, Fault<L>>

Narrows to the domain outcome, or the non-domain fault. let d = e.rejected()?; propagates the fault into any enclosing Fail<_, L> (or a Failure carrier) via the blanket From<Fault<L>>.

Source

pub fn as_rejected(&self) -> Option<&D>

Source

pub fn is_transient(&self) -> bool

Source

pub fn is_fatal(&self) -> bool

Source

pub fn is_denied(&self) -> bool

Source

pub fn message(&self) -> String
where D: Rejection,

The operator-safe one-line text for this failure — exactly what record writes to exception.message, for a boundary that must persist it rather than (or as well as) record it. Transient/ Fatal: the whole source() chain joined with ": ". Denied: its Display. Rejected: the rejection’s code, never its message (display discipline — a rejection’s message may embed caller-supplied input).

Source

pub fn narrow_transient(self, attempts: u32) -> Fail<D, WithoutTransient<L>>
where L::Transient: NarrowTransient<L::Fatal>,

Consumes the Transient lane, yielding the same rejection over L with its transient slot disabled. An exhausted transient becomes Fatal(Exhausted), carrying attempts and the last transient as its source.

Source

pub fn narrow_denied(self) -> Fail<D, WithoutDenied<L>>
where L::Denied: NarrowDenied<L::Fatal>,

Narrows away the Denied lane: a denial at a boundary with no subject (code running as the system) becomes Fatal(Denied) with the Denied as its source.

Source

pub fn narrow_rejected(self) -> Fault<L>
where D: Rejection, L: LaneProfile<Fatal = Fatal>,

Narrows away the Rejected lane: a rejection at a boundary with no caller to correct it is an invariant violation, and becomes Fatal(Invariant) with the rejection as its source — the same rule a partial #[lift(.., unhandled = fatal)] applies. Nothing is left to reject, so the result is a Fault. with_opaque_source: d’s Display may embed caller-supplied input (the same display discipline Rejection documents everywhere else), so source() still returns it for a handler or test to downcast_ref, but message_chain must not walk into it.

Trait Implementations§

Source§

impl<D: Clone, L: Clone + LaneProfile> Clone for Fail<D, L>
where L::Denied: Clone, L::Transient: Clone, L::Fatal: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug, L: Debug + LaneProfile> Debug for Fail<D, L>
where L::Denied: Debug, L::Transient: Debug, L::Fatal: Debug,

Source§

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

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

impl<D: Display, L: LaneProfile> Display for Fail<D, L>

Source§

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

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

impl<D: Error + 'static, L: LaneProfile> Error for Fail<D, L>

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<D: Rejection, L: LaneProfile> Failure for Fail<D, L>

Source§

type Rejection = D

Source§

type Lanes = L

Source§

fn into_fail(self) -> Fail<Self::Rejection, Self::Lanes>

Source§

fn from_fail(f: Fail<Self::Rejection, Self::Lanes>) -> Self

Source§

fn as_fail(&self) -> &Fail<Self::Rejection, Self::Lanes>

Source§

fn lane(&self) -> Lane

Source§

fn is_transient(&self) -> bool

Source§

impl<D, L> From<Denied> for Fail<D, L>
where L: LaneProfile<Denied = Denied> + LaneProfile,

Source§

fn from(d: Denied) -> Self

Converts to this type from the input type.
Source§

impl<D, L> From<Exhausted> for Fail<D, L>
where L: LaneProfile<Fatal = Fatal> + LaneProfile,

Source§

fn from(e: Exhausted) -> Self

Converts to this type from the input type.
Source§

impl<D, L> From<Fatal> for Fail<D, L>
where L: LaneProfile<Fatal = Fatal> + LaneProfile,

Source§

fn from(f: Fatal) -> Self

Converts to this type from the input type.
Source§

impl<D, S: LaneProfile, L: LaneProfile> From<Fault<S>> for Fail<D, L>
where S::Denied: Into<L::Denied>, S::Transient: Into<L::Transient>, S::Fatal: Into<L::Fatal>,

The real blanket the Infallible encoding could not have: Fault<L> is not Fail, so this does not overlap From<T> for T.

Source§

fn from(f: Fault<S>) -> Self

Converts to this type from the input type.
Source§

impl<D, L> From<Transient> for Fail<D, L>
where L: LaneProfile<Transient = Transient> + LaneProfile,

Source§

fn from(t: Transient) -> Self

Converts to this type from the input type.
Source§

impl<W: Classify, D: Lift<W::Rejected, Unmapped = Infallible>, M: LaneProfile> From<W> for Fail<D, M>

? into a Fail: the rejected part must be absorbed totally by D (no decision left for the call site to make with .widen()); the wrapper’s lanes must fit the destination’s profile. Replaces the narrower impl<C: Rejection, D: From<C>, L> From<C> for Fail<D, L> — a bare rejection is the W::Rejected = W, W::Lanes = NoLanes case of this.

Source§

fn from(w: W) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<D, L> Freeze for Fail<D, L>

§

impl<D, L> RefUnwindSafe for Fail<D, L>

§

impl<D, L> Send for Fail<D, L>
where D: Send, <L as LaneProfile>::Denied: Send, <L as LaneProfile>::Transient: Send, <L as LaneProfile>::Fatal: Send,

§

impl<D, L> Sync for Fail<D, L>
where D: Sync, <L as LaneProfile>::Denied: Sync, <L as LaneProfile>::Transient: Sync, <L as LaneProfile>::Fatal: Sync,

§

impl<D, L> Unpin for Fail<D, L>
where D: Unpin, <L as LaneProfile>::Denied: Unpin, <L as LaneProfile>::Transient: Unpin, <L as LaneProfile>::Fatal: Unpin,

§

impl<D, L> UnsafeUnpin for Fail<D, L>

§

impl<D, L> UnwindSafe for Fail<D, L>

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<F> Laned for F
where F: Failure, <<F as Failure>::Lanes as LaneProfile>::Transient: NarrowTransient<<<F as Failure>::Lanes as LaneProfile>::Fatal>,

Source§

type WithoutTransient = Fail<<F as Failure>::Rejection, <<F as Failure>::Lanes as LaneProfile>::WithoutTransient>

Source§

fn lane(&self) -> Lane

Source§

fn narrow_transient(self, attempts: u32) -> <F as Laned>::WithoutTransient

Source§

fn message(&self) -> String

The operator-safe one-line text for this failure — exactly what record writes to exception.message, for a boundary that must persist it rather than (or as well as) record it. Transient/ Fatal: the whole source() chain joined with ": ". Denied: its Display. Rejected: the rejection’s code, never its message (display discipline — a rejection’s message may embed caller-supplied input).
Source§

fn is_transient(&self) -> bool

Source§

fn is_fatal(&self) -> bool

Source§

fn is_denied(&self) -> bool

Source§

impl<P> Lift<!> for P

Source§

type Unmapped = !

Source§

fn lift(x: !) -> Result<P, <P as Lift<!>>::Unmapped>

Source§

impl<X, P> Lift<X> for P
where X: Rejection, P: From<X>,

Source§

type Unmapped = !

Source§

fn lift(x: X) -> Result<P, <P as Lift<X>>::Unmapped>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.