thiserror
derive(Error) for struct and enum error types (by dtolnay)
anyhow
Flexible concrete Error type built on std::error::Error (by dtolnay)
thiserror | anyhow | |
---|---|---|
16 | 14 | |
4,851 | 5,882 | |
2.3% | 2.0% | |
9.2 | 8.2 | |
about 2 months ago | 17 days ago | |
Rust | Rust | |
Apache License 2.0 | Apache License 2.0 |
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
thiserror
Posts with mentions or reviews of thiserror.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2024-12-19.
-
Error Stacking in Rust
Inspired by this blog post I just added an `#[implicit]` field feature to the `thiserror` crate. It makes it easy to automatically annotate errors with things like code location (per this blog post), a timestamp, or a backtrace without requiring further modifications to the thiserror crate. I'm hoping that dtolnay will consider it. You can find my PR here: https://github.com/dtolnay/thiserror/pull/402
-
Rust Learning Note: Exception Handling
We can utilize third-party libraries to simplify the code above. For example thiserror (https://github.com/dtolnay/thiserror) provides convenien derive macro for Error trait:
- I can't get my mind around Result, Option, or basically how control flow works in most Rust programs
-
Ideas for crafting CLI in Rust
thiserror crate makes it easy to do so using macros on CliError enum.
-
I love building a startup in Rust. I wouldn't pick it again.
Depending on your use case, thiserror and/or anyhow.
-
Hey Rustaceans! Got a question? Ask here (52/2022)!
What is the benefit of splitting a proc-macro crate into (usually) two crates, proc_macro_crate and proc_macro_crate_impl? Why not just have one crate? Does it offer any benefits to to overall compilation times? An example of this can be seen in the thiserror crate where there's a thiserror and thiserror_impl crate.
-
Parsing of DeviceId
You might want to use thiserror to generate implementation for Error and Display.
-
Rust for web development: 3 years later
thiserror for my error types.
-
What crates would you consider essential?
thiserror - https://crates.io/crates/thiserror
-
Generics can make your Go code slower
I dont think you realize how ridiculous this comment is. Youre comparing 10 lines of Go, with 200 of Rust:
https://github.com/dtolnay/thiserror/blob/master/src/lib.rs
anyhow
Posts with mentions or reviews of anyhow.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2023-02-17.
-
Visualizing memory layout of Rust's data types
Couple of questions, which are because of my limited knowledge.
1) The pointer provenance you're referring to, is that CHERI or the pointer provenance currently in use in macOS?
2) Reading through your post, are you talking about the same as the anyhow's error implementation? https://github.com/dtolnay/anyhow/blob/af0937ef72fbaf9784a6c...
-
I love building a startup in Rust. I wouldn't pick it again.
Depending on your use case, thiserror and/or anyhow.
-
Why Rust?
There is ? as well as the anyhow(https://github.com/dtolnay/anyhow) crate that deals with long nested result chains.
- Anyhow/src/ensure.rs: Rust macro with 675 lines
-
Is this a good way of handling errors in Rust?
There are crates out there that help you reduce this boiler plate. thiserror is good for creating custom errors and color-eyre or anyhow are good for dynamic errors.
-
Looking for general advice on toy project
Give anyhow a look.
-
Oops, I Did It Again...I Made A Rust Web API And It Was Not That Difficult
I've brought anyhow::Result into scope, making error handling super easy to use. We don't need to specify all our Error types. It can automatically convert any errors that implement std::error::Error, which should be all of them. If an error propagates all the way up to main(), we'll get all the info it's captured printed to stdout.
-
Idiomatic way to return/break if Err/None
Alternatively, if you've got a lot of error types and you're outside a library (so directly in a binary where you don't plan to reuse code elsewhere) you can use anyhow. This gives you an error type you can basically propagate any other error through. On top of that you can attach context information at every return. It's basically a more complicated Result>.
-
Using workspace for modularization is kind of painful?
One approach is to define a separate error type for each crate and then use anyhow, eyre or Box to wrap the error, whever a function can return errors originating in several different crates.
What are some alternatives?
When comparing thiserror and anyhow you can also consider the following projects:
color-eyre - Custom hooks for colorful human oriented error reports via panics and the eyre crate
eyre - A trait object based error handling type for easy idiomatic error handling and reporting in Rust applications
futures-rs - Zero-cost asynchronous programming in Rust
fenix - Rust toolchains and rust-analyzer nightly for Nix [maintainer=@figsoda]
proposal - Go Project Design Documents