Skip to main content

Fail

Enum Fail 

Source
pub enum Fail<D, L = Profile<true, true, true>>
where L: LaneProfile,
{ Rejected(D), Denied(<L as LaneProfile>::Denied), Transient(<L as LaneProfile>::Transient), Fatal(<L as LaneProfile>::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 as LaneProfile>::Denied)

§

Transient(<L as LaneProfile>::Transient)

§

Fatal(<L as LaneProfile>::Fatal)

Implementations§

Source§

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

Source

pub fn lanes(&self) -> LaneRef<'_, D>

A borrowed view of the current lane.

Source§

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

Source

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

Source§

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

Source§

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

Source

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

Source§

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

Source

pub fn lane(&self) -> Lane

Source

pub fn widen<P, M>(self) -> Fail<P, M>
where P: Lift<D>, M: LaneProfile, <L as LaneProfile>::Denied: Into<<M as LaneProfile>::Denied>, <L as LaneProfile>::Transient: Into<<M as LaneProfile>::Transient>, <L as LaneProfile>::Fatal: Into<<M as LaneProfile>::Fatal>, <P as Lift<D>>::Unmapped: UnmappedInto<<M as LaneProfile>::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>( self, f: impl FnOnce(D) -> Result<P, Fatal>, ) -> Fail<P, M>
where M: LaneProfile<Fatal = Fatal>, <L as LaneProfile>::Denied: Into<<M as LaneProfile>::Denied>, <L as LaneProfile>::Transient: Into<<M as LaneProfile>::Transient>, <L as LaneProfile>::Fatal: Into<<M as LaneProfile>::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 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, <L as LaneProfile>::WithoutTransient>
where <L as LaneProfile>::Transient: NarrowTransient<<L as LaneProfile>::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, <L as LaneProfile>::WithoutDenied>
where <L as LaneProfile>::Denied: NarrowDenied<<L as LaneProfile>::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, L> Clone for Fail<D, L>

Source§

fn clone(&self) -> Fail<D, L>

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, L> Debug for Fail<D, L>

Source§

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

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

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

Source§

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

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

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

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<W, D, M> From<W> for Fail<D, M>
where W: IntoLanes, D: Lift<<W as IntoLanes>::Rejected, Unmapped = !>, M: LaneProfile, <W as IntoLanes>::Shape: IntoFail, <<W as IntoLanes>::Lanes as LaneProfile>::Denied: Into<<M as LaneProfile>::Denied>, <<W as IntoLanes>::Lanes as LaneProfile>::Transient: Into<<M as LaneProfile>::Transient>, <<W as IntoLanes>::Lanes as LaneProfile>::Fatal: Into<<M as LaneProfile>::Fatal>,

? into a Fail: the rejected part must be absorbed totally by D (no decision left for the call site to make with .widen()); the source’s lanes must fit the destination’s profile.

Source§

fn from(w: W) -> Fail<D, M>

Converts to this type from the input type.
Source§

impl<D, L> Laned for Fail<D, L>
where D: Rejection, L: LaneProfile, <L as LaneProfile>::Transient: NarrowTransient<<L as LaneProfile>::Fatal>,

Note the NarrowTransient bound: a profile that admits Transient but not Fatal is not Laned, so retry cannot be handed one. Retrying an operation that claims it can never fail permanently is exactly the contradiction the bound rules out.

Source§

type WithoutTransient = Fail<D, <L as LaneProfile>::WithoutTransient>

Source§

fn lane(&self) -> Lane

Source§

fn level(&self) -> Level

The operator level of this failure: the lane’s default (Lane::level), overridden only by a Rejected outcome’s Rejection::level.
Source§

fn narrow_transient( self, attempts: u32, ) -> <Fail<D, L> 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<D, L> Repr for Fail<D, L>
where L: LaneProfile,

Source§

impl<D, L> Reshape for Fail<D, L>
where L: LaneProfile,

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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