pub struct Error(/* private fields */);Expand description
A comprehensive structural error type, intended exclusively for human consumption.
Implementations§
source§impl Error
impl Error
pub fn from(x: impl Display) -> Error
sourcepub fn also(self, incidental: Error) -> Error
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")
],
),
);
}Trait Implementations§
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> 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
Mutably borrows from an owned value. Read more
source§impl<T> DebugDisplay for Twhere
T: Debug,
impl<T> DebugDisplay for Twhere
T: Debug,
source§impl<T> ErrContext for T
impl<T> ErrContext for T
source§fn context(self, message: &'static str) -> Error
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
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.