pub struct Fatal {
pub kind: FatalKind,
pub context: Option<Cow<'static, str>>,
/* private fields */
}Expand description
A failure that will not succeed on retry: a bug, a misconfiguration, or corrupt state.
kind, context and source are for operators (traces, logs) and for
tests (which may downcast_ref the source to assert what happened).
Production code never inspects a Fatal’s payload: the response to a
Fatal is the same regardless of its source — stop, surface, page. If you
find yourself needing the payload, the outcome was a value or a
Rejection and the API should be changed, not the call site.
Fields§
§kind: FatalKind§context: Option<Cow<'static, str>>Implementations§
Source§impl Fatal
impl Fatal
pub fn new(kind: FatalKind) -> Fatal
Sourcepub fn from_error(
kind: FatalKind,
e: impl Error + Send + Sync + 'static,
) -> Fatal
pub fn from_error( kind: FatalKind, e: impl Error + Send + Sync + 'static, ) -> Fatal
Fatal::new plus Fatal::with_source, as one call — the common
shape at a classification site that has the error in hand.
Sourcepub fn with_source(self, e: impl Error + Send + Sync + 'static) -> Fatal
pub fn with_source(self, e: impl Error + Send + Sync + 'static) -> Fatal
As Transient::with_source. Takes self so a Fatal built from a
lane table can be given its source afterwards.
Sourcepub fn from_boxed(kind: FatalKind, e: Box<dyn Error + Send + Sync>) -> Fatal
pub fn from_boxed(kind: FatalKind, e: Box<dyn Error + Send + Sync>) -> Fatal
Explicit escape hatch for a source that only arrives boxed. There is
no From<Box<dyn Error>> — a caller must say out loud that it is
discarding whatever lane the boxed error might have carried.
Sourcepub fn from_dyn(kind: FatalKind, e: &(dyn Error + 'static)) -> Fatal
pub fn from_dyn(kind: FatalKind, e: &(dyn Error + 'static)) -> Fatal
Fatal::new(kind) with the error’s whole Display chain as context —
the by-reference form for a boundary holding a &dyn Error it cannot
keep as source. The same fold Fault::classify
makes in its rule 3, with the kind chosen by the caller.
pub fn invariant(msg: impl Into<Cow<'static, str>>) -> Fatal
pub fn with_context(self, c: impl Into<Cow<'static, str>>) -> Fatal
Trait Implementations§
Source§impl Error for Fatal
impl Error for Fatal
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()
Auto Trait Implementations§
impl !RefUnwindSafe for Fatal
impl !UnwindSafe for Fatal
impl Freeze for Fatal
impl Send for Fatal
impl Sync for Fatal
impl Unpin for Fatal
impl UnsafeUnpin for Fatal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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