micro_errors
Utilities to deal with errors without taking the derive macro approach.
Exposes a struct ErrorChain
to typically be used within the Err
variant of Result
. ErrorChain
contains a generic payload and a recusive struct, ErrorLink
, which in turn contains either a summary message or a backtrace (intended to be of the last link). See below.
;
For the generic payload as String
, utilities have been implemented to aid chaining (e.g., .map_err
'ing).
Gist
Creating an ErrorChain
from a non ErrorChain
.
Creating an ErrorChain
from an existing ErrorChain
.
Output of displaying/println!
ing the error being something like below.
Error no. 0: I dunno
Error no. 1: who I be
Error no. 2: key glock
Approximate backtrace of error no. 2:
0: micro_errors::ErrorLink::severed
at ./src/lib.rs:58:23
1: micro_errors::ErrorChain<alloc::string::String>::start
at ./src/lib.rs:76:13
2: micro_errors::test_crate
at ./src/lib.rs:14:22
3: micro_errors::test_crate::{{closure}}
at ./src/lib.rs:4:16
Again, creating an ErrorChain
from an existing ErrorChain
.