Skip to main content

Fault

Enum Fault 

Source
pub enum Fault<L = Profile<true, true, true>>
where L: LaneProfile,
{ Denied(<L as LaneProfile>::Denied), Transient(<L as LaneProfile>::Transient), Fatal(<L as LaneProfile>::Fatal), }
Expand description

Fail minus the Rejected lane: what an operation that cannot reject (nothing about it is the caller’s to correct) returns. Reads return Fault<L>; writes return Fail<{Entity}ConstraintViolation, L> — the type itself says whether a call can ever hand back a domain outcome.

Variants§

§

Denied(<L as LaneProfile>::Denied)

§

Transient(<L as LaneProfile>::Transient)

§

Fatal(<L as LaneProfile>::Fatal)

Implementations§

Source§

impl<L> Fault<L>
where L: LaneProfile,

Source

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

A borrowed view of the current lane.

Source§

impl Fault

Source

pub fn classify(e: &(dyn Error + 'static)) -> Fault

Classify an erased error at a boundary that only has &(dyn Error + 'static) — e.g. &*boxed for a Box<dyn Error> that is not Send/Sync and so cannot become a lane payload’s source (Fatal’s and Transient’s sources are Arc<dyn Error + Send + Sync>, by design — see the crate README). No Send/Sync bound is needed here: every step only ever borrows e. Call before the next .await — the chain being walked may not be Send.

  1. A lane payload anywhere in the chain wins, carried through intact — kind, context, and (now Send/Sync, having been cloned out) its own original source.
  2. Else, for each blessed foreign type whose classify-* feature is enabled (sqlx::Error, serde_json::Error, reqwest::Error, in that order), the first one found anywhere in the chain is classified exactly as that feature’s impl Classify would — with the error’s message as context in place of the source this function cannot move out of a shared reference.
  3. Else Fatal(FatalKind::Dependency), with message_chain (private) as context.

Rule 3 is a safety default, not a shrug: an error this function cannot otherwise classify must still surface as something a boundary pages on, never silently as nothing. A lane payload found by this rule may itself be a Denied — narrowing it away, if the boundary has no subject, is the caller’s explicit next step (see Fault::narrow_denied).

Source§

impl<L> Fault<L>
where L: LaneProfile,

Source

pub fn lane(&self) -> Lane

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

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.

Source

pub fn narrow_transient( self, attempts: u32, ) -> Fault<<L as LaneProfile>::WithoutTransient>
where <L as LaneProfile>::Transient: NarrowTransient<<L as LaneProfile>::Fatal>,

Consumes the Transient lane, yielding the same profile with its transient slot disabled. attempts is what the retry loop counted; an exhausted transient becomes Fatal(Exhausted) with the last transient as its source.

Source

pub fn narrow_denied(self) -> Fault<<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§

impl<L> Fault<L>
where L: LaneProfile<Denied = Denied>,

Borrowed lane accessors. min_exhaustive_patterns lets a by-value match name only the lanes a profile enables, but a borrowed match still demands an arm for every variant. These accessors are the borrowed form, so no caller ever has to write a match *never {} arm. Each is available only when the profile enables that lane, so e.as_denied() on a no-denial profile is a compile error rather than a permanent None.

Source

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

Source§

impl<L> Fault<L>
where L: LaneProfile<Transient = Transient>,

Source§

impl<L> Fault<L>
where L: LaneProfile<Fatal = Fatal>,

Source

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

Source§

impl<L> Fault<L>
where L: LaneProfile,

Source

pub fn widen<M>(self) -> Fault<M>

Trait Implementations§

Source§

impl<L> Clone for Fault<L>

Source§

fn clone(&self) -> Fault<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<L> Debug for Fault<L>

Source§

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

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

impl<L> Display for Fault<L>
where L: LaneProfile,

Source§

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

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

impl<L> Error for Fault<L>
where 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, M> From<W> for Fault<M>
where W: IntoLanes<Rejected = !>, M: LaneProfile, <W as IntoLanes>::Shape: IntoFault, <<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 Fault: only for a source that never rejects, and only into a profile that holds all of the source’s lanes. A rejection, or a mixed wrapper, entering a Fault function stays an explicit narrowing (narrow_rejected), never a silent ?.

Why this is coherent with the reflexive From<T> for T: Fault<M>’s own Shape is kind::Fault, which is not [kind::IntoFault], and every type and marker involved is local to errlanes. Do not replace the marker bound with associated-type equality across several impls on a generic W: two such impls overlap (rust-lang/rust#20400).

Source§

fn from(w: W) -> Fault<M>

Converts to this type from the input type.
Source§

impl<L> Laned for Fault<L>
where L: LaneProfile, <L as LaneProfile>::Transient: NarrowTransient<<L as LaneProfile>::Fatal>,

Source§

type WithoutTransient = Fault<<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, ) -> <Fault<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<L> Repr for Fault<L>
where L: LaneProfile,

Source§

impl<L> Reshape for Fault<L>
where L: LaneProfile,

Auto Trait Implementations§

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