Created
July 23, 2021 16:27
-
-
Save aaripurna/7786d2127b9119db413e9032fd62c18b to your computer and use it in GitHub Desktop.
error handling rust
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
fn some_operation() -> Result<str, Error> { | |
if succeded() { | |
Ok("We did it") | |
} else { | |
Err(Error::from("this not working")) | |
} | |
} | |
fn main() { | |
match some_operation() { | |
Ok(data) => println!("Success!, {}", data), | |
Err(msg) => println!("Error!, {}", msg) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment