Replace uncaught exception for unhanded error.
Comment on How One Uncaught Rust Exception Took Out Cloudflare
solrize@lemmy.ml 1 day ago
Rust has exceptions? Is that new?
calcopiritus@lemmy.world 1 day ago
sugar_in_your_tea@sh.itjust.works 1 day ago
No, it’s a panic, so it’s more similar to a segfault.
calcopiritus@lemmy.world 17 hours ago
An unhanded error will always result on a panic (or a halt I guess). You cannot continue the execution of the program without handling an error (remember, just ignoring it is a form of handling). You either handle the error and continue execution, or you don’t and stop execution.
A panic is very far from a segfault. In apparent result, it is the same. However, a panic is a controlled stopping of the program’s execution. A segfault is a forced execution stop by the OS.
But the OS can only know that it has to segfault if a program accesses memory outside its control.
If the program accesses memory that it’s under it’s control, but is outside bounds, then the program will not stop the execution, and this is way worse.
sugar_in_your_tea@sh.itjust.works 13 hours ago
Yes, it’s not the same since you get a stacktrace (if enabled) and a message, but it’s the closest thing you get in safe rust (outside compiler bugs). I compare it to a segfault because it’s almost as unhandleble.
Basically, you don’t want a panic to crash your program in most cases. If you do, make it explicit (i.e. with
expect()).unwrap()tells me the value is absolutely there or the dev is lazy, and I always assume the latter unless there’s an explanation (or it’s obvious from context) otherwise.
Kissaki@feddit.org 21 hours ago
unhanded error
underhanded error /s
vext01@lemmy.sdf.org 1 day ago
Well… catch_unwind, but i don’t think you can rely on it.
NGram@piefed.ca 1 day ago
No, the article is just not very precise with its words. It was causing the program to panic.
dan@upvote.au 1 day ago
They’re probably trying to write it in a way that non-Rust-developers can understand.