|
|
|
|
|
by willglynn
3350 days ago
|
|
> The kind of exceptions that unwind the stack until some part of the code up the stack catches the exception. Rust panics result in unwinding the stack: https://doc.rust-lang.org/nomicon/unwinding.html try!/? is preferred for handling errors, but if you "know" that a Result or an Option has a value, you can unwrap() or expect() it, and you'll get a panic if you're wrong. |
|
In both languages panic() is for "this shouldn't happen" fatal errors, not for signaling errors to the caller, the way Java or C# use exceptions.
My comment was in response to person basically saying "checked exceptions in Java would be good if only they implemented it the way Swift/Rust did".