Skip to main content

ClassificationMarker

Struct ClassificationMarker 

Source
pub struct ClassificationMarker { /* private fields */ }
Expand description

A transparent classification marker with an optional owned source and no diagnostic of its own.

Unlike Message, markers only supply classification metadata, never a visible diagnostic. Use Message to combine a message, class, and scalar values in one causal error; use a marker to classify an existing concrete error without changing its diagnostic or recovery payload. Self::with_source() adds a classification to an existing error while preserving its concrete type and diagnostic. The associated constants, such as Self::NOT_FOUND, are owned class-only markers. A custom error can return Some(const { &ClassificationMarker::NOT_FOUND }) from its source() implementation without defining a static. Self::with_class() creates an owned class-only marker, including for Class::Io with a specific I/O kind.

Diagnostic iterators, downcasts, cause selection, and exception/test reports skip all markers, retaining their real descendants. crate::classify() still inspects markers. Raw standard-error sources can still expose markers. A report with only class-only markers falls back to displaying the root classification. If cause selection cannot choose a unique real descendant, it can likewise fall back to the stored marker root. Preserve real std::io::Error sources: the marker itself has no I/O origin for crate::types::Classification::io_kind().

Implementations§

Source§

impl ClassificationMarker

Source

pub const VALIDATION: Self

A hidden marker for invalid input.

Source

pub const CORRUPTION: Self

A hidden marker for malformed or internally inconsistent data.

Source

pub const NOT_FOUND: Self

A hidden marker for a requested resource that does not exist.

Source

pub const RETRYABLE: Self

A hidden marker for an operation which may succeed when retried.

Source

pub const ALLOCATION_LIMIT: Self

A hidden marker for an application-configured allocation limit being exceeded.

Source

pub const ALLOCATION_FAILURE: Self

A hidden marker for an unrepresentable allocation size or memory that could not be reserved.

Source

pub fn with_source( class: Class, source: impl Error + Send + Sync + 'static, ) -> Self

Add class to source, preserving its concrete type and diagnostic without a visible wrapper.

Source

pub const fn with_class(class: Class) -> Self

Create a hidden metadata leaf, suitable for a custom error’s static source. Prefer the associated constants, such as Self::NOT_FOUND, for fixed classifications.

Source

pub fn class(&self) -> Class

Return the classification supplied by this marker.

Trait Implementations§

Source§

impl Debug for ClassificationMarker

Source§

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

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

impl Display for ClassificationMarker

Source§

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

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

impl Error for ClassificationMarker

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

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> ErrorExt for T
where T: Error + Send + Sync + 'static,

Source§

fn raise(self) -> Exn<Self>
where Self: Sized,

Raise this error as a new exception.
Source§

fn and_raise<T: Error + Send + Sync + 'static>(self, context: T) -> Exn<T>
where Self: Sized,

Raise this error as a child of a new exception with the given context error. Read more
Source§

fn raise_erased(self) -> Exn
where Self: Sized,

Raise this error as a new exception, with type erasure.
Source§

fn raise_all<T, I>(self, sources: I) -> Exn<Self>
where Self: Sized, T: Error + Send + Sync + 'static, I: IntoIterator, I::Item: Into<Exn<T>>,

Raise this error as a new exception, with sources as causes.
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<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.