error_chain/
example_generated.rs

1//! These modules show an example of code generated by the macro. **IT MUST NOT BE
2//! USED OUTSIDE THIS CRATE**.
3//!
4//! This is the basic error structure. You can see that `ErrorKind`
5//! has been populated in a variety of ways. All `ErrorKind`s get a
6//! `Msg` variant for basic errors. When strings are converted to
7//! `ErrorKind`s they become `ErrorKind::Msg`. The "links" defined in
8//! the macro are expanded to the `Inner` variant, and the
9//! "foreign links" to the `Io` variant.
10//!
11//! Both types come with a variety of `From` conversions as well:
12//! `Error` can be created from `ErrorKind`, `&str` and `String`,
13//! and the `links` and `foreign_links` error types. `ErrorKind`
14//! can be created from the corresponding `ErrorKind`s of the link
15//! types, as well as from `&str` and `String`.
16//!
17//! `into()` and `From::from` are used heavily to massage types into
18//! the right shape. Which one to use in any specific case depends on
19//! the influence of type inference, but there are some patterns that
20//! arise frequently.
21
22/// Another code generated by the macro.
23pub mod inner {
24    error_chain! {}
25}
26
27error_chain! {
28    links {
29        Inner(inner::Error, inner::ErrorKind) #[doc = "Link to another `ErrorChain`."];
30    }
31    foreign_links {
32        Io(::std::io::Error) #[doc = "Link to a `std::io::Error` type."];
33    }
34    errors {
35        #[doc = "A custom error kind."]
36        Custom
37    }
38}