Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate failure;
- pub mod errors {
- pub use failure::{Error, ResultExt};
- pub type Result<T> = ::std::result::Result<T, Error>;
- }
- pub use errors::{Result, ResultExt};
- fn run() -> Result<()> {
- some_function()
- .context("we called the function but it failed ;_;")?;
- Ok(())
- }
- fn main() {
- if let Err(err) = run() {
- eprintln!("Error: {}", err);
- for cause in err.causes().skip(1) {
- eprintln!("Because: {}", cause);
- }
- std::process::exit(1);
- }
- }
Add Comment
Please, Sign In to add comment