Created
October 20, 2016 13:00
-
-
Save erasin/44542df8e3b8faf2d6be3cb1bfafdfe7 to your computer and use it in GitHub Desktop.
rust error test
This file contains hidden or 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
use std::error::Error; | |
fn main() { | |
match f1() { | |
Ok(_) => {} | |
Err(e) => { | |
println!("{}", e); | |
} | |
} | |
} | |
fn f1() -> Result<(), Box<Error>> { | |
if true { | |
let msg = "错误信息"; | |
return Err(Box::from(format!("Error: {}", msg))); | |
} | |
// try!(f1); | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment