Struct loga::types::Error

source ·
pub struct Error(/* private fields */);
Expand description

A comprehensive structural error type, intended exclusively for human consumption.

Implementations§

source§

impl Error

source

pub fn from(x: impl Display) -> Error

source

pub fn also(self, incidental: Error) -> Error

Extend the base error with a new incidental (occurred while handling the base error) error. Use like e.also(log, new_e);.

Examples found in repository?
examples/fatal.rs (lines 15-23)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
fn main() {
    fatal(
        agg_err(
            "The main thing failed",
            vec![
                err_with("The primary system exploded", ea!(att1 = "Hi", att2 = 423))
                    .also(
                        err_with(
                            "An incidental_error with a threateningly long message that might be able to wrap if I extend the length somewhat further and then some I guess going by editor width this might not be quite enough",
                            ea!(
                                another_attr =
                                    "This is a very long message, hopefully it gets wrapped somewhere between the start and the end of the screen"
                            ),
                        ),
                    )
                    .also(err("Nothing much else to add")),
                err("Just tacking this one on too")
            ],
        ),
    );
}
source

pub fn context(self, message: &'static str) -> Error

Return a new error adding a simple string message as a layer of context.

source

pub fn log_context<F: Flags>(self, log: &Log<F>, message: &'static str) -> Error

Return a new error adding a layer of context including all attributes in the provided log along with the specified message.

source

pub fn log_context_with<F: Flags>( self, log: &Log<F>, message: &'static str, attrs: impl Fn(&mut HashMap<&'static str, String>) ) -> Error

Return a new error adding a layer of context including all attributes in the provided log along with the specified message and new attributes.

Trait Implementations§

source§

impl Clone for Error

source§

fn clone(&self) -> Error

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Error

source§

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

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

impl Display for Error

source§

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

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

impl<T: Error> From<T> for Error

source§

fn from(value: T) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe for Error

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> DebugDisplay for T
where T: Debug,

source§

impl<T> ErrContext for T
where T: Into<Error>,

source§

fn context(self, message: &'static str) -> Error

Add a simple context string onto an error, converting it to loga::Error in the process.
source§

fn context_with( self, message: &'static str, attrs: impl Fn(&mut HashMap<&'static str, String>) ) -> Error

Add a simple context string and attributes pairs onto an error, converting it to loga::Error in the process.
source§

fn stack_context<F>(self, log: &Log<F>, message: &'static str) -> Error
where F: Flags,

Add attributes from the log as well as a simple context string to an error, converting it to loga::Error in the process.
source§

fn stack_context_with<F>( self, log: &Log<F>, message: &'static str, attrs: impl Fn(&mut HashMap<&'static str, String>) ) -> Error
where F: Flags,

Add attributes from the log as well as the specified attributes and a simple context string to an error, converting it to loga::Error in the process.
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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> ToOwned for T
where T: Clone,

§

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§

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

§

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

§

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.