Skip to main content

SanthErrorBuilder

Struct SanthErrorBuilder 

Source
pub struct SanthErrorBuilder<State = NoFix> { /* private fields */ }
Expand description

Builder for SanthError.

Uses a typestate pattern to enforce at compile time that .fix() is called before .build().

Implementations§

Source§

impl<State> SanthErrorBuilder<State>

Source

pub fn with_context( self, key: impl Into<Cow<'static, str>>, value: impl Display, ) -> Self

Add a key-value diagnostic context entry.

Source

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

Attach a source error to the cause chain.

Source

pub fn with_location(self, location: ErrorLocation) -> Self

Attach a location to the error.

Source§

impl SanthErrorBuilder<NoFix>

Source

pub fn fix(self, fix: impl Into<String>) -> SanthErrorBuilder<HasFix>

Provide the mandatory fix hint.

Transitions the builder to the HasFix state, allowing .build() to be called.

Source§

impl SanthErrorBuilder<HasFix>

Source

pub fn build(self) -> SanthError

Build the SanthError.

A fix hint that does not already start with "Fix: " is normalised by prefixing it, so the built error always upholds the "Fix: " contract. This never panics.

Trait Implementations§

Source§

impl<State: Debug> Debug for SanthErrorBuilder<State>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<State = NoFix> !RefUnwindSafe for SanthErrorBuilder<State>

§

impl<State = NoFix> !UnwindSafe for SanthErrorBuilder<State>

§

impl<State> Freeze for SanthErrorBuilder<State>

§

impl<State> Send for SanthErrorBuilder<State>
where State: Send,

§

impl<State> Sync for SanthErrorBuilder<State>
where State: Sync,

§

impl<State> Unpin for SanthErrorBuilder<State>
where State: Unpin,

§

impl<State> UnsafeUnpin for SanthErrorBuilder<State>

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> 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, 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.