Skip to content

Instantly share code, notes, and snippets.

@aaripurna
Created July 23, 2021 16:27
Show Gist options
  • Save aaripurna/7786d2127b9119db413e9032fd62c18b to your computer and use it in GitHub Desktop.
Save aaripurna/7786d2127b9119db413e9032fd62c18b to your computer and use it in GitHub Desktop.
error handling rust
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