This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example with all the possible syntax.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#[macro_use] | ||
extern crate error_chain; | ||
|
||
pub mod inner { | ||
error_chain! {} | ||
} | ||
|
||
#[cfg(feature = "a_feature")] | ||
pub mod feature { | ||
error_chain! {} | ||
} | ||
|
||
error_chain! { | ||
// Types generated by the macro. If empty of absent, it defaults to | ||
// Error, ErrorKind, Result; | ||
types { | ||
// With custom names: | ||
MyError, MyErrorKind, MyResult; | ||
// Without the `Result` wrapper: | ||
// Error, ErrorKind; | ||
} | ||
|
||
// Automatic bindings to others error types generated by `error_chain!`. | ||
links { | ||
inner::Error, Inner; | ||
// Attributes can be added at the end of the declaration. | ||
feature::Error, Feature, #[cfg(feature = "a_feature")]; | ||
} | ||
|
||
// Bindings to types implementing std::error::Error. | ||
foreign_links { | ||
::std::io::Error, Io; | ||
} | ||
} | ||
|
||
fn main() {} |