thiserror

A derive macro for ergonomic, zero-boilerplate custom error types in Rust.

Library
Cargo
v2.0.20
5,517stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
76/100Good
Development Activity72
Maintenance80
Community52
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
88/100Excellent
Architecture85
Code Quality90
Innovation88
Learning Curve88

thiserror is a lightweight derive macro that implements Rust’s std::error::Error trait for custom error types, eliminating the boilerplate of hand-written Display and source() implementations. Developers annotate an enum or struct with #[derive(Error)] and per-variant #[error(”…”)] messages, and thiserror generates the trait implementations at compile time with no runtime cost and no trace left in the crate’s public API.

Widely regarded as the standard choice for library authors who want precise, structured error types (as opposed to anyhow’s single dynamic error type for application code), thiserror is used throughout the Rust ecosystem by crates that need typed, matchable error enums with readable messages.

What You Get

  • A #[derive(Error, Debug)] macro that implements std::error::Error for any struct or enum
  • Automatic Display generation via #[error(”…”)] message strings with field interpolation shorthand ({field}, {0}, {field:?})
  • Automatic From impls for variants annotated with #[from], enabling seamless ? operator conversions
  • source() chaining via #[source] or #[from] fields, plus Backtrace capture via #[backtrace] on nightly compilers
  • #[error(transparent)] support for forwarding Display/source straight through to an inner error, useful for opaque public error types

Common Use Cases

  • Defining a library’s public error enum with one variant per failure mode and a human-readable message per variant
  • Wrapping upstream errors (io::Error, serde_json::Error, etc.) with #[from] for seamless ? propagation across module boundaries
  • Building an opaque top-level error type via #[error(transparent)] to hide internal representation from callers while keeping it free to evolve

Under The Hood

Architecture — The project splits into two crates: the public thiserror crate (src/lib.rs) re-exports a single derive macro and a handful of small runtime helper modules (private.rs, var.rs, aserror.rs, display.rs, provide.rs) that generated code relies on for trait-bound checks and provide() support, while the actual codegen lives in the thiserror-impl proc-macro crate (impl/): ast.rs parses the struct/enum into an internal model, attr.rs parses the #[error(…)], #[from], #[source], #[backtrace] attributes, fmt.rs implements the field-interpolation shorthand parser, valid.rs enforces macro-usage constraints at compile time, and expand.rs assembles the final Display/Error/From token streams. build.rs probes the active compiler version to conditionally enable nightly-only Backtrace/provide() features.

Tech Stack — Pure Rust, 2021 edition, MSRV 1.71. The impl crate depends on the standard proc-macro trio (syn, quote, proc-macro2); the public thiserror crate itself has zero runtime dependencies beyond thiserror-impl, keeping compile times and dependency trees minimal. Dual-licensed MIT OR Apache-2.0. Structured as a Cargo workspace with impl/ and tests/no-std/ as members.

Code Quality — Backed by an extensive test suite: unit-style integration tests (test_display.rs, test_from.rs, test_source.rs, test_transparent.rs, test_backtrace.rs, test_generics.rs, test_option.rs, test_path.rs, test_expr.rs, test_lints.rs) plus a 76-file trybuild tests/ui/ suite that asserts the macro’s compile-error messages stay stable and helpful. Clippy lint allowances are explicitly documented rather than silently suppressed. Over 800 commits and a decorated release history (89 releases) reflect long-term maintenance discipline from a single primary maintainer (dtolnay).

API Design — The public surface is intentionally minimal: one derive macro plus a small set of attributes (#[error], #[from], #[source], #[backtrace]). The field-interpolation shorthand (#[error(“{field}”)] instead of write!(”{}”, self.field)) removes nearly all boilerplate from the common case, and the README explicitly contrasts thiserror against anyhow to help users pick the right tool. Because generated code never appears in the crate’s public API, switching to or away from thiserror is a non-breaking change for consumers.

Used by 51 apps in this directory

Rust
64%
Apache 2.0

agentgateway

AI Development · Developer Tools

4,420

An open source AI-native proxy that secures, observes, and governs agent-to-LLM, agent-to-tool, and agent-to-agent communication through MCP, A2A, and unified LLM routing.

View details
88
Repo Health
82
Technical
72
Dependency
Built with
Rust64%
Go24%
Updated yesterday
Dart
74%
AGPL 3.0

AppFlowy

Productivity · Project Management · Collaboration

75,729

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
66
Dependency
Built with
Dart74%
Rust24%
Updated 1 weeks ago
TypeScript
92%
GPL 3.0

Blinko

Knowledge Management · Note Taking

10,880

A self-hosted, AI-powered card note-taking tool that lets you capture fleeting thoughts instantly and retrieve them with natural language search.

View details
83
Repo Health
69
Technical
65
Dependency
Built with
TypeScript92%
Updated 2 weeks ago
TypeScript
49%
AGPL 3.0

BrowserOS

Browser · AI Assistants

13,248

The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.

View details
87
Repo Health
82
Technical
69
Dependency
Built with
TypeScript49%
Rust22%
Python16%
Updated today
TypeScript
91%
MIT

bunqueue

Developer Tools · Devops

535

High-performance job queue for Bun — SQLite persistence, cron scheduling, DLQ, S3 backups, and a native MCP server, all without Redis.

View details
74
Repo Health
83
Technical
76
Dependency
Built with
TypeScript91%
Updated 2 weeks ago
Rust
54%
Other

Cameleer

AI Agents

23

A local-first desktop workspace for managing AI agents in an enterprise-style workflow — agent directory, Kanban task tracking, workspace chat, and a full runtime/audit log of agent actions and tool approvals.

View details
48
Repo Health
65
Technical
76
Dependency
Built with
Rust54%
JavaScript24%
TypeScript15%
Updated 4 weeks ago
TypeScript
55%
Other

Cap

Team Chat · Video Conferencing

20,986

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
Rust
52%
Apache 2.0

cocoindex

Data Engineering · AI Development

11,350

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
87
Repo Health
85
Technical
64
Dependency
Built with
Rust52%
Python48%
Updated yesterday
Go
32%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,247

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go32%
Rust31%
C21%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search