FJ7MWHMLIDTBGJJNKCNS5GIBQIJBUQRXLQEAFOCVZI7O4NA4XGSAC VPPGYSBICWMGVK6V7PRHP4OP2WRAFABRDKFJJ33AQAITJ65VPR4QC K7UY4GCWKGWKQKFKOE4ETLPGEMN5LDIGBOQKN57Q24UUQGYU2WOAC LNM226ITXRMWOSX6GOJ4HO72BWFRBDKQTEZMF4QUJUACUIOKIEJQC GFUITBG5JGUCDMG34FEMPPJAZGQKURXA5L2RYS6YOQC4DIQGASMAC EKYR4HDT6DHI7H5YMSHEBHXLPDCA2X2XNXYHDKHWGMPHNVTUBCMQC YWW5TKMSPEGRZ52FQZ3SC4C3DEZ57U5XUO4LHZC34BJA7QR5NSCQC 6BNRWGF55J5M3YBWYNTWJCRJQSEHY7YRKOUBV43W7I2HCTFDJHUQC CITEDKPB6MKVZUEYEDE5ZKTNVY35HCOAXKDPYG7YLLEOVFNMSRXQC OXKWHQFHTDDOWX3QDMHDWHCT3HFKWQS7Z7DEL3ILJBA7GNITA4GAC ZDN7BJ3JA3VL4AYWX3SV24GHP6NCAETJVAKAXKMIZTLHTWLUNMOQC This crate is a fork of `anyhow` by @dtolnay. My goal in writing this crate isto explore new ways to associate context with errors, to cleanly separate theconcept of an error and context about an error, and to more clearly communicatethe intended usage of this crate via changes to the API.
This crate is a fork of `anyhow` by @dtolnay. By default this crate does notadd any new features that `anyhow` doesn't already support. If you're notalready familiar with `anyhow` and you're just looking for a catch all errortype you should probably just stick with `anyhow`. The magic of this crate iswhen you need to add extra information to anyhow beyond what you can insertinto the error chain. For an example of a customized version of eyre check out[`jane-eyre`](https://github.com/yaahc/jane-eyre).My goal in writing this crate is to explore new ways to associate context witherrors, to cleanly separate the concept of an error and context about an error,and to more clearly communicate the intended usage of this crate via changes tothe API.
* Addition of the [`eyre::EyreContext`] trait and a type parameter on the core errorhandling type which users can use to insert custom forms of context intotheir catch all error handling type.
* Addition of the [`eyre::EyreContext`] trait and a type parameter on the coreerror handling type which users can use to insert custom forms of contextinto their catch-all error handling type.
describing it as an error type in its own right. This type is not an error,it contains errors that it masqerades as, and provides helpers for creatingnew errors to wrap those errors and for displaying those chains of errors,and the included context, to the end user. The goal is to make it obviousthat this type is meant to be used when the only way you expect to handleerrors is to print them.
describing it as an error type in its own right. What is and isn't an erroris a fuzzy concept, for the purposes of this crate though errors are typesthat implement `std::error::Error`, and you'll notice that this traitimplementation is conspicuously absent on `ErrReport`. Instead it containserrors that it masqerades as, and provides helpers for creating new errors towrap those errors and for displaying those chains of errors, and the includedcontext, to the end user. The goal is to make it obvious that this type ismeant to be used when the only way you expect to handle errors is to printthem.
that it is unrelated to the [`eyre::EyreContext`] and the context member, andis only for inserting new errors into the chain of errors.* Addition of a new `context` function on [`eyre::ErrReport`] to assist withextracting members from the inner Context, which is used by[`eyre::ErrReport`] to extract [`std::backtrace::Backtrace`]'s from genericcontexts types.
that it is unrelated to the [`eyre::EyreContext`] trait and member, and isonly for inserting new errors into the chain of errors.* Addition of new context helpers on `EyreContext` (`member_ref`/`member_mut`)and `context`/`context_mut` on `ErrReport` for working with the customcontext and extracting forms of context based on their type independent ofthe type of the custom context.
* `fn context_raw(&self, typeid TypeID) -> Option<&dyn Any>` - For extractingarbitrary members from a context based on their type.This method is like a flexible version of the `fn backtrace(&self)` method onthe `Error` trait. In the future we will likely support extracting `Backtrace`sand `SpanTrace`s by default by relying on the implementation of `context_raw`provided by the user.
Here is how the `eyre::DefaultContext` type uses this to return `Backtrace`s.```rustfn context_raw(&self, typeid: TypeId) -> Option<&dyn Any> {if typeid == TypeId::of::<Backtrace>() {self.backtrace.as_ref().map(|b| b as &dyn Any)} else {None}}```
### Optional Methods* `fn member_ref(&self, typeid TypeID) -> Option<&dyn Any>` - For extractingarbitrary members from a context based on their type and `member_mut` forgetting a mutable reference in the same way.This method is like a flexible version of the `fn backtrace(&self)` method onthe `Error` trait. The main `ErrReport` type provides versions of these methodsthat use type inference to get the typeID that should be used by inner trait fnto pick a member to return.**Note**: The `backtrace()` fn on `ErrReport` relies on the implementation ofthis function to get the backtrace from the user provided context if oneexists. If you wish your type to guaruntee that it captures a backtrace for anyerror it wraps you **must** implement `member_ref` and provide a path to returna `Backtrace` type like below.
Here is how the `eyre::DefaultContext` type uses this to return `Backtrace`s.```rustfn member_ref(&self, typeid: TypeId) -> Option<&dyn Any> {if typeid == TypeId::of::<Backtrace>() {self.backtrace.as_ref().map(|b| b as &dyn Any)} else {None}}```