Rust Error Handling

The cluster focuses on discussions about Rust's Result type, ? operator, and error propagation mechanisms, often praising it as superior to exceptions in C++/Java or verbose checks in Go/C, with mentions of crates like anyhow and thiserror.

➡️ Stable 0.8x Programming Languages
3,420
Comments
18
Years Active
5
Top Authors
#1800
Topic ID

Activity Over Time

2009
3
2010
8
2011
13
2012
31
2013
36
2014
89
2015
134
2016
229
2017
175
2018
200
2019
236
2020
262
2021
357
2022
297
2023
435
2024
365
2025
512
2026
38

Keywords

AFAIK handling.html TimeoutException IMO lang.org RAII crates.io doc.rust blog.rust NotFound error rust err error handling errors handling return code type nil

Sample Comments

nindalf Dec 22, 2022 View on HN

You might like how Rust does error handling. Rather than a function returning a triple of (val, error) where the error can be ignored, functions return Result. If you want to get the T, you must write code that handles both possibilities. If your function instead wants the T and propagate the E upwards if it exists, you can do that with one character - “?”

arielby Sep 1, 2015 View on HN

Rust's error handling (try! and error-interoperability) do this well.

szemet Mar 6, 2017 View on HN

I guess many people don't have problem with the 'errors are values' concept, just would like to handle them with much less boilerplate: like in Rust or Haskell...

the_clarence Nov 10, 2018 View on HN

There is no better way to do errors imo, unless you're going the erlang way of "let it fail". Errors can be passed to the caller the same way exceptions are, and it becomes an endless pursuit of where the error is actually being handled (if at all). I agree that some syntax sugar helps, see Rust, but it doesn't completely fixes the problem.

Yoric Dec 18, 2024 View on HN

Is it time to brag about Rust error-handling or should we wait a little?

koakuma-chan Apr 27, 2025 View on HN

Rust has error handling personality.

influxmoment Oct 7, 2023 View on HN

Don't care for the way they do exceptional handling. Make errors part of the type system

Animats Oct 19, 2023 View on HN

Yes.Rust struggled with that for about three rounds of verbose error handling, until finally settling on "Result" and "?". That seems to be about right. C++ exceptions are too much. Writing it all out as in C and Go is too little. The Rust solution is a good midpoint.

roca Aug 13, 2020 View on HN

Yes! Rust's error handling story is excellent.You can still swallow errors if you want to but you have to manually write unwrap() so it's much more visible.

mayhew Jul 14, 2016 View on HN

Agreed, Rust's way of error handling with Result and try! (or ?) is far superior.