This is a Rust crate that provides a convenient derive macro (#[derive(Error)]) for implementing std::error::Error on your custom error types (structs or enums). The goal is to enable library authors to build expressive, typed error types, with readable Display implementations (via #[error("...")] annotations) as well as From conversions (#[from]), source tracking (#[source]), and optionally backtraces. It is designed so that switching from handwritten error implementation to using this error is not a breaking change: you retain the same API. The README shows examples: an enum with variants annotated by #[error("…")] and #[from] fields to derive the appropriate trait impls. The crate expects rustc ≥ 1.68+. The README also outlines how you choose; use thiserror if you care about designing your own error-types (e.g., for libraries) vs anyhow for applications.

Features

  • #[derive(Error)] macro to implement std::error::Error for your types
  • #[error("…")] annotation for Display message formatting with interpolation
  • #[from] attribute for automatic From conversions from underlying error types
  • #[source] attribute (or implied) for error chaining
  • Backtrace field support (via #[backtrace], nightly-only)
  • Library-friendly design: no impact on public API if switching implementation

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

Apache License V2.0

Follow derive(Error)

derive(Error) Web Site

Other Useful Business Software
Forever Free Full-Stack Observability | Grafana Cloud Icon
Forever Free Full-Stack Observability | Grafana Cloud

Our generous forever free tier includes the full platform, including the AI Assistant, for 3 users with 10k metrics, 50GB logs, and 50GB traces.

Built on open standards like Prometheus and OpenTelemetry, Grafana Cloud includes Kubernetes Monitoring, Application Observability, Incident Response, plus the AI-powered Grafana Assistant. Get started with our generous free tier today.
Create free account
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of derive(Error)!

Additional Project Details

Programming Language

Rust

Related Categories

Rust Libraries

Registered

2025-11-14