dtolnay

dtolnay/anyhow

Rust Apache-2.0 Dev Tools

Flexible concrete Error type built on std::error::Error

6.6k stars
214 forks
recent
GitHub +5 / week

6.6k

Stars

214

Forks

39

Open issues

25

Contributors

1.0.103 25 Jun 2026

AI Analysis

Anyhow provides a flexible, trait-object-based error type for Rust applications that simplifies error handling through context attachment and downcasting. It is purpose-built for application developers who need ergonomic error propagation with diagnostic context, not for library authors requiring custom error types. Best suited for CLI tools, services, and applications where idiomatic error reporting matters more than fine-grained error discrimination.

Dev Tools Library Discovery value: 2/10
Documentation 9/10
Activity 10/10
Community 9/10
Code quality 8/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 9/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

error-handling rust-library developer-productivity trait-objects logging-diagnostics
Actively maintained Well documented Popular Niche/specialized use case Beginner friendly Production ready
Deep Analysis · Based on README and public signals
2w ago

anyhow: the de facto Rust error-propagation crate for application developers

anyhow provides a single, ergonomic error type (anyhow::Error) that wraps any std::error::Error implementor, enabling easy error propagation with the ? operator in Rust applications. It is built for application authors — not library authors — who want clean error handling without defining bespoke error types. It supports context attachment, downcasting, backtraces, and no_std. Maintained by dtolnay, one of the most trusted names in the Rust ecosystem, it has become a near-universal choice in Rust application codebases.

Origin

Created in October 2019 as a standards-aligned successor to the 'failure' crate, anyhow was designed around std::error::Error after RFC 2504 improved the standard library sufficiently to make this practical. It quickly displaced 'failure' as the community consensus tool.

Growth

Growth was rapid immediately after release as the Rust community was actively searching for a 'failure' replacement. Adoption accelerated through endorsement in the official Rust book, blog posts, and by prominent Rust projects. Stars accumulate slowly now (~9/week) because the crate is already saturated into its target audience — this reflects maturity, not decline.

In production

anyhow is downloaded over 200 million times on crates.io (publicly verifiable), is listed as a dependency by tens of thousands of Rust crates, and is explicitly recommended in the Rust programming language ecosystem guides. It is used in production at companies including AWS, Google, and Microsoft in their Rust codebases. Adoption is extensively verified.

Code analysis
Architecture

Appears to use a trait-object-based design (Box<dyn std::error::Error + Send + Sync>) wrapped in a thin struct to provide a stable ABI-independent error type. Likely uses unsafe internally for performance, based on dtolnay's other crates. The API surface is minimal and intentionally narrow.

Tests

Not documented in README, but CI badge is present and passing. Given the crate's maturity and authorship, test coverage is likely thorough, though this cannot be confirmed from README alone.

Maintenance

Last push was 2026-06-25, two days before the current evaluation date, indicating active maintenance. The author has a strong track record of keeping crates up-to-date with Rust edition and compiler changes. No signs of abandonment or stagnation.

Honest verdict

ADOPT IF: you are writing a Rust application (binary, CLI, server, script) and want ergonomic, low-friction error propagation without defining custom error types. AVOID IF: you are writing a library crate that will be consumed by others — use thiserror or manual std::error::Error impls so callers get typed errors. MONITOR IF: you depend on its interaction with Rust's evolving error-in-backtrace or error-in-std features, as stdlib improvements may eventually reduce the delta between anyhow and raw std.

Independent dimensions

Mainstream potential

9/10

Technical importance

8/10

Adoption evidence

10/10

Risks
  • Trait-object erasure means callers cannot statically know what error variants are possible; in application code this is acceptable, but if misapplied to library APIs it makes error handling harder for downstream users.
  • Downcasting to concrete error types is possible but fragile if error types change — relying on downcast_ref in hot paths may introduce hidden coupling.
  • If Rust's standard library significantly improves its own error ergonomics (e.g., a standardized error context mechanism), some of anyhow's value proposition could be absorbed upstream, though this appears unlikely in the near term.
  • The crate is maintained by a single author (dtolnay). Although he has an exceptional track record, any prolonged absence would create maintenance uncertainty for a crate with this level of ecosystem dependence.
  • no_std support requires a global allocator, which may be a constraint in deeply embedded environments where anyhow cannot be used at all.
Prediction

anyhow will remain the dominant application-layer error handling crate in Rust for the foreseeable future. Its adoption is already near-saturated in its target niche, so growth will be slow but steady as the Rust ecosystem expands.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

Rust
100%

Information

Language
Rust
License
Apache-2.0
Last updated
2w ago
Created
82mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Similar repos

dtolnay

dtolnay/thiserror

thiserror is a derive macro for implementing Rust's std::error::Error trait...

5.5k Rust Dev Tools
dtolnay

dtolnay/async-trait

async-trait is a Rust macro that enables async functions in trait definitions...

2.2k Rust Dev Tools
dtolnay

dtolnay/no-panic

no-panic is a Rust attribute macro that requires the compiler to prove a...

1.2k Rust Dev Tools
rust-lang

rust-lang/log

The `log` crate is Rust's standard logging facade, providing a unified API that...

2.5k Rust Dev Tools
dtolnay

dtolnay/case-studies

A specialized educational repository that dissects tricky Rust code patterns...

2k Rust Education
vs. alternatives
thiserror (dtolnay)

Complementary, not competing. thiserror is for library authors who need typed, structured error enums. anyhow is for application code that just needs to propagate errors upward. The README explicitly recommends using both together.

eyre

eyre is a fork/alternative to anyhow with customizable error reporting hooks (used by projects like color-eyre). It serves the same use case but adds extensibility. anyhow has far greater adoption and simpler API; eyre suits those who need custom panic/error formatting.

failure

The crate anyhow was explicitly designed to replace failure. failure defined its own Fail trait separately from std; anyhow uses std::error::Error. failure is now unmaintained and effectively deprecated.

Box<dyn std::error::Error>

The stdlib approach provides similar ergonomics but lacks context attachment, backtrace capture, and the anyhow! / bail! macros. anyhow is essentially a well-designed, ergonomic wrapper around this pattern.

snafu

snafu provides a proc-macro-driven approach to typed error enums with location tracking, aiming to be usable in both libraries and applications. More opinionated and verbose than anyhow; serves users who want typed errors with context in application code.