Skip to main content

MetricError

Struct MetricError 

Source
#[non_exhaustive]
pub struct MetricError(/* private fields */);
Expand description

The error every generic-surface call returns, inside At<…>.

One word wide (the fields live behind a Box), so At<MetricError> is two words and MetricResult<T> stays cheap on the ? path.

Implementations§

Source§

impl MetricError

Source

pub fn from_located<E>(kind: ErrorKind, detail: At<E>) -> At<Self>
where E: Error + Send + Sync + 'static,

Transfer an existing native location trace into this envelope.

Source

pub fn new(kind: ErrorKind) -> Self

An error of kind with no detail.

Source

pub fn from_detail<E>(kind: ErrorKind, detail: E) -> Self
where E: Error + Send + Sync + 'static,

An error of kind wrapping the metric’s own error.

Source

pub fn stopped(reason: StopReason) -> Self

The Stopped error for reason.

Source

pub fn with_detail<E>(self, detail: E) -> Self
where E: Error + Send + Sync + 'static,

Attach the metric’s own error (boxed; reachable via source()).

Source

pub fn with_boxed_detail(self, detail: Box<dyn Error + Send + Sync>) -> Self

Attach an already-boxed detail error.

Source

pub fn with_metric(self, family: &'static str) -> Self

Stamp the originating metric family ("fsim", "cvvdp").

Source

pub fn with_message(self, message: impl Into<Cow<'static, str>>) -> Self

Attach a human-readable message (shown when there is no detail).

Source

pub fn kind(&self) -> ErrorKind

The coarse classification.

Source

pub fn metric(&self) -> Option<&'static str>

The originating metric family, if stamped.

Source

pub fn message(&self) -> Option<&str>

The attached message, if any.

Source

pub fn detail(&self) -> Option<&(dyn Error + 'static)>

The metric’s own error, if any.

Trait Implementations§

Source§

impl AsStopReason for MetricError

Source§

fn as_stop_reason(&self) -> Option<StopReason>

The [StopReason] this error represents, or None for any other failure.
Source§

impl Debug for MetricError

Source§

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

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

impl Display for MetricError

Source§

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

"{metric}: {kind}: {message}: {detail}", omitting absent parts.

Source§

impl Error for MetricError

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 From<StopReason> for MetricError

Source§

fn from(reason: StopReason) -> Self

Converts to this type from the input type.

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
§

impl<E> ErrorAtExt for E
where E: Error,

§

fn start_at(self) -> At<E>

Wrap this value in At<E> and add the caller’s location. If allocation fails, the error is still wrapped but trace may be empty. 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<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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.