Expand description
§the cloneable_errors crate
this is basically the core functionality of anyhow, but written from scratch, in safe rust.
this library was previously an internal error_handling crate in DeArrow Browser
and was licensed together with the entire project under AGPL.
it was spun off into it’s own public crate and is now licensed under MIT.
§why?
anyhow errors are not cloneable - caching them is annoying, especially if you want to add more context later on
this crate aims to be a simpler, hopefully less annoying alternative if you do the things I do
- errors use Arc<> internally
- there’s a serializable variant that drops a lot of data, but makes it easy to send error info between workers or over the wire
§deps
- no required dependencies
- serde optionally required for serializing the serializable error variant (enable the
serdefeature) - anyhow optionally required for turning anyhow errors into serializable errors (enable the
anyhowfeature)
§optional features
serde: derives (de)serialization traits for theSerializableErrorstructbincode: derivesEncodeandDecodetraits for theSerializableErrorstructanyhow: adds compatibility functions and traits foranyhowerror stacks (using those will flatten the errors stacks intoSerializableErrors)extensions: enablesErrorContextobjects to hold arbitrary “extension” attributes (side effect: increases the size of that struct)
Macros§
- anyhow
- Create a new
ErrorContextstack - bail
- Create a new
ErrorContextstack usinganyhow!and immediately return it asResult::Err
Structs§
- Error
Context - An annotated error stack
- Error
Iterator ErrorIterator- iterates over the chain ofError::source- Serializable
Error - An error stack with all messages flattened into strings, trivial to (de)serialize
Enums§
- Shared
String - A helper enum for easily cloneable strings
Traits§
- Anyhow
ErrContext anyhow - A helper trait for converting an anyhow error stack into an
ErrorContextstack - Anyhow
ResContext anyhow - A helper trait for converting anyhow results into
ErrorContextresults - ErrContext
- A helper trait for annotating any Error with an
ErrorContext - Extension
extensions - This trait should be implemented by any structs that are intended to be used as error extensions.
- Into
Error Iterator - ResContext
- A helper trait for annotating result errors and empty options
- ResExtensions
extensions - A helper trait for extending error variants of
Result<T, ErrorContext>