# dtolnay/anyhow

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/dtolnay-anyhow).**

6,569 stars · 212 forks · Rust · Apache-2.0

## Links

- GitHub: https://github.com/dtolnay/anyhow
- awesome-repositories: https://awesome-repositories.com/repository/dtolnay-anyhow.md

## Description

Anyhow is a dynamic error handling library for Rust applications that provides a flexible error container using type erasure. It serves as a tool for simplifying error signatures by wrapping diverse failure types into a single object, allowing for the propagation of any error that implements the standard error trait without requiring a custom enumeration for every function.

The project functions as an error context provider by attaching high-level diagnostic information and recording execution stack traces at the point of failure. It enables the recovery of concrete error implementations from generic containers through downcasting and supports the generation of ad hoc errors using string interpolation.

## Tags

### Part of an Awesome List

- [Error Type Unifications](https://awesome-repositories.com/f/awesome-lists/devtools/error-handling/error-type-unifications.md) — Provides a dynamic error container that wraps diverse failure types into a single trait object to simplify function signatures. ([source](https://github.com/dtolnay/anyhow/blob/master/README.md))
- [Error Handling](https://awesome-repositories.com/f/awesome-lists/devtools/error-handling.md) — Implements a dynamic error type for capturing and propagating any Rust error implementing the standard trait.
- [Error Object Downcasters](https://awesome-repositories.com/f/awesome-lists/devtools/error-handling/error-type-unifications/error-object-downcasters.md) — Enables casting a generic error trait object back to its original concrete type.

### Software Engineering & Architecture

- [Dynamic Error Containers](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/standardized-error-traits/dynamic-error-containers.md) — Provides a trait-object based wrapper for managing diverse error types without custom enums.
- [Error Contextualization](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/error-management/application-error-handlers/error-contextualization.md) — Enriches errors with source location and high-level diagnostic metadata. ([source](https://github.com/dtolnay/anyhow/blob/master/rust-toolchain.toml))
- [Heap-Allocated Error Containers](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/error-object-creation/uniform-error-objects/heap-allocated-error-containers.md) — Uses heap allocation to allow diverse error types to be handled by a single uniform container.
- [Standardized Error Traits](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/standardized-error-traits.md) — Manages disparate error types through a dynamic trait object implementing the standard Error trait.
- [Error Propagation Systems](https://awesome-repositories.com/f/software-engineering-architecture/error-propagation-systems.md) — Simplifies the propagation of various error types without requiring exhaustive custom enums.
- [Error Wrapping](https://awesome-repositories.com/f/software-engineering-architecture/error-reporting/custom-error-interfaces/error-wrapping.md) — Nests errors within a recursive structure to append high-level diagnostic context.
- [Ad Hoc Error Generation](https://awesome-repositories.com/f/software-engineering-architecture/error-mapping-strategies/self-describing-error-strings/ad-hoc-error-generation.md) — Provides a mechanism to generate formatted error messages without defining a custom type.

### Programming Languages & Runtimes

- [Type-Erasure Error Containers](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/language-features/language-extensions/trait-implementations/trait-object-polymorphism/type-erasure-error-containers.md) — Wraps diverse error types into a single dynamic type using trait-object based erasure.
- [Rust Application Debugging](https://awesome-repositories.com/f/programming-languages-runtimes/rust-application-debugging.md) — Captures backtraces and diagnostic information to identify the cause and location of failures.

### System Administration & Monitoring

- [Runtime Failure Backtrace Capturers](https://awesome-repositories.com/f/system-administration-monitoring/diagnostic-tools/diagnostics/failure-analysis-tools/crash-reporters/runtime-failure-backtrace-capturers.md) — Automatically captures the execution stack at the point of failure for debugging.

### Web Development

- [Ad Hoc Error Generation](https://awesome-repositories.com/f/web-development/error-handling/ad-hoc-error-generation.md) — Generates one-off error messages using string interpolation for rapid failure reporting. ([source](https://github.com/dtolnay/anyhow#readme))
