Guest User

Untitled

a guest
Jul 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. extern crate failure;
  2.  
  3. pub mod errors {
  4. pub use failure::{Error, ResultExt};
  5. pub type Result<T> = ::std::result::Result<T, Error>;
  6. }
  7. pub use errors::{Result, ResultExt};
  8.  
  9. fn run() -> Result<()> {
  10. some_function()
  11. .context("we called the function but it failed ;_;")?;
  12. Ok(())
  13. }
  14.  
  15. fn main() {
  16. if let Err(err) = run() {
  17. eprintln!("Error: {}", err);
  18. for cause in err.causes().skip(1) {
  19. eprintln!("Because: {}", cause);
  20. }
  21. std::process::exit(1);
  22. }
  23. }
Add Comment
Please, Sign In to add comment