Rust Panic Handling

This cluster centers on debates about Rust's panic mechanism, including its intended use for unrecoverable errors, recoverability via panic=unwind or panic=abort, comparisons to exceptions, and best practices like unwrap() versus explicit error handling.

➡️ Stable 1.0x Programming Languages
2,784
Comments
17
Years Active
5
Top Authors
#5416
Topic ID

Activity Over Time

2010
7
2011
1
2012
36
2013
50
2014
73
2015
71
2016
165
2017
164
2018
103
2019
119
2020
210
2021
203
2022
370
2023
307
2024
236
2025
656
2026
15

Keywords

unreachable.html IMHO FFI lang.org systemsconf.io doc.rust play.rust array.get API panic panics rust unwind stdlib handling error handling error recover errors

Sample Comments

ahoka Oct 12, 2025 View on HN

Rust has panic, although intended for “unrecoverable” errors only.

Georgelemental Nov 12, 2023 View on HN

Rust has panics that could appear anywhere.

nextaccountic Aug 5, 2024 View on HN

Oh, so it's like Rust's panic=abort

usrnm Dec 5, 2025 View on HN

I really don't see how it would've helped. In go or Rust you'd just get a panic, which is in no way different.

nextaccountic Nov 12, 2023 View on HN

Rust panics can be catched too, but it's true that it's less common than in languages with exceptions

bluejekyll Jan 13, 2019 View on HN

Let’s not go too far, Rust has plenty of panics at runtime.

josephg Jan 24, 2024 View on HN

Oh no, I didn't know this. I'm adding panic = "abort" to all my projects. If I wanted exceptions I wouldn't be using rust.

layer8 Oct 2, 2022 View on HN

I’m referring to the fact that ubiquitous functions like unwrap() panic if the programmer has made an error. Guarding against such panics is outside of the scope of Rust-the-language, and has to be handled through external means. There are linters for C as well.

kibwen Mar 21, 2016 View on HN

Rust does not have exceptions, not even in the limited capacity that Go sort-of has. It's legal for a Rust implementation to translate panics into aborts, which means that they cannot be relied upon as an error-handling mechanism. Furthermore, the means to halt unwinding in Rust exists only to prevent memory unsafety from occurring when Rust is embedded in another language via the C interface, because unwinding across an FFI boundary is undefined behavior. In fact the exact mechanism used i

kibwen Nov 19, 2025 View on HN

> Not familiar with Rust but it seems unwrap is such a thing that would be banned.Panics aren't exceptions, any "panic" in Rust can be thought of as an abort of the process (Rust binaries have the explicit option to implement panics as aborts). Companies like Dropbox do exactly this in their similar Rust-based systems, so it wouldn't surprise me if Cloudflare does the same."Banning exceptions" wouldn't have done anything here, what you're l