Skip to content

Commit

Permalink
Update catch_unwind example (google#1356)
Browse files Browse the repository at this point in the history
Fixes google#1352.

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
  • Loading branch information
manish7017 and mgeisler authored Oct 12, 2023
1 parent de0e8e6 commit 358d7da
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/error-handling/panic-unwind.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ use std::panic;
fn main() {
let result = panic::catch_unwind(|| {
println!("hello!");
"No problem here!"
});
assert!(result.is_ok());
println!("{result:?}");
let result = panic::catch_unwind(|| {
panic!("oh no!");
});
assert!(result.is_err());
println!("{result:?}");
}
```

* This can be useful in servers which should keep running even if a single
- This can be useful in servers which should keep running even if a single
request crashes.
* This does not work if `panic = 'abort'` is set in your `Cargo.toml`.
- This does not work if `panic = 'abort'` is set in your `Cargo.toml`.

0 comments on commit 358d7da

Please sign in to comment.