# dtolnay/thiserror

**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-thiserror).**

5,459 stars · 210 forks · Rust · Apache-2.0

## Links

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

## Description

thiserror is a Rust error handling library and procedural macro designed to define custom error types. It functions as a trait implementation automator that generates the necessary code for standard library error traits at compile time.

The library focuses on eliminating boilerplate by using derive macros to automatically implement display and source methods. It allows for the creation of custom error structs and enums that can map low-level errors to high-level variants while preserving the original cause and backtrace information.

Its capabilities cover custom error formatting through template interpolation, error propagation management, and the integration of stack backtraces for debugging. It also provides mechanisms to automate error conversion and trace error origins via designated fields.

## Tags

### Programming Languages & Runtimes

- [Error Handling Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/error-handling-libraries.md) — Provides a comprehensive framework for defining custom error types in Rust using derive macros.
- [Automated](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/language-features/language-extensions/trait-implementations/automated.md) — Automatically implements the Display and Error traits for custom Rust types to eliminate boilerplate.
- [Automatic Trait Conversions](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/language-features/language-extensions/trait-implementations/automatic-trait-conversions.md) — Automatically generates From trait implementations to convert lower-level errors into custom high-level variants.
- [Procedural Macros](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/language-features/metaprogramming/procedural-macros.md) — Uses procedural macros to generate trait implementations for error types at compile time.
- [Rust Error Handling Tooling](https://awesome-repositories.com/f/programming-languages-runtimes/rust-error-handling-tooling.md) — Provides a comprehensive solution for defining custom error types in Rust with minimal boilerplate via trait automation.
- [Rust Application Debugging](https://awesome-repositories.com/f/programming-languages-runtimes/rust-application-debugging.md) — Supports diagnosing Rust application failures through the integration of source methods and backtraces.

### Software Engineering & Architecture

- [Macro-Driven Transformations](https://awesome-repositories.com/f/software-engineering-architecture/compile-time-code-generation/macro-driven-transformations.md) — Uses Rust procedural macros to generate the standard Display and Error trait implementations at compile time.
- [Compile-Time Code Generation](https://awesome-repositories.com/f/software-engineering-architecture/compile-time-code-generation.md) — Eliminates manual boilerplate by generating trait implementations at compile time using declarative macros.
- [Automatic Error Conversions](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/automatic-error-conversions.md) — Automates the transformation of low-level errors into custom variants using attribute-driven conversion logic. ([source](https://github.com/dtolnay/thiserror/blob/master/README.md))
- [Error Mapping Generators](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/error-management/error-type-compositions/error-mapping-generators.md) — Provides a mechanism to map low-level errors to high-level variants while preserving original cause and backtrace information.
- [Error Propagation Systems](https://awesome-repositories.com/f/software-engineering-architecture/error-propagation-systems.md) — Manages the hierarchy of failure causes by wrapping low-level errors into high-level custom variants.
- [Custom Error Type Definitions](https://awesome-repositories.com/f/software-engineering-architecture/error-reporting/custom-error-interfaces/custom-error-type-definitions.md) — Facilitates the definition of custom error enums and structs with minimal boilerplate using derive macros. ([source](https://github.com/dtolnay/thiserror#readme))
- [Error Wrapping](https://awesome-repositories.com/f/software-engineering-architecture/error-reporting/custom-error-interfaces/error-wrapping.md) — Wraps lower-level errors within custom types to maintain the error chain while providing a unified interface.
- [Error Source Resolution](https://awesome-repositories.com/f/software-engineering-architecture/error-source-resolution.md) — Implements the source method by automatically resolving and forwarding the underlying causal error from designated fields.
- [Declarative Error Formatting](https://awesome-repositories.com/f/software-engineering-architecture/declarative-error-formatting.md) — Creates user-friendly error messages in Rust using templates that automatically include data from error fields.
- [Error Detail Proxying](https://awesome-repositories.com/f/software-engineering-architecture/error-detail-proxying.md) — Allows errors to proxy their display and source methods to an underlying error, hiding internal implementation details. ([source](https://github.com/dtolnay/thiserror#readme))
- [Error Template Interpolation](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/format-error-translators/terminal-error-formatting/runtime-table-error-formatting/error-template-interpolation.md) — Enables the creation of user-facing error messages using templates that interpolate data from error fields. ([source](https://github.com/dtolnay/thiserror/blob/master/README.md))
- [Display-Based Error Messages](https://awesome-repositories.com/f/software-engineering-architecture/error-handling/localized-error-messages/display-based-error-messages.md) — Generates human-readable error strings by implementing the Display trait with interpolated field values. ([source](https://github.com/dtolnay/thiserror#readme))

### Part of an Awesome List

- [Error Source Tracing](https://awesome-repositories.com/f/awesome-lists/devtools/error-handling/error-source-tracing.md) — Implements source methods to return the original low-level error that caused the current failure. ([source](https://github.com/dtolnay/thiserror#readme))
- [Developer Utilities](https://awesome-repositories.com/f/awesome-lists/devtools/developer-utilities.md) — Library for defining custom error types in Rust.

### System Administration & Monitoring

- [Causal](https://awesome-repositories.com/f/system-administration-monitoring/error-tracking/causal.md) — Provides the ability to identify and return the underlying cause of an error via the source method. ([source](https://github.com/dtolnay/thiserror/blob/master/README.md))
- [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) — Integrates stack backtrace capture and propagation across nested error layers for debugging. ([source](https://github.com/dtolnay/thiserror#readme))

### Development Tools & Productivity

- [Stack Trace Capture](https://awesome-repositories.com/f/development-tools-productivity/custom-component-wrapping/error-boundary-wrappers/stack-trace-capture.md) — Captures stack trace data within error types by detecting backtrace fields or forwarding source errors. ([source](https://github.com/dtolnay/thiserror/blob/master/README.md))
- [Template String Interpolation](https://awesome-repositories.com/f/development-tools-productivity/template-string-interpolation.md) — Provides a mechanism to interpolate fields into error messages using template strings defined in attributes.
