/fuse-rust:rust-error-handlingfrom fuse-rust
Designs Rust error handling with thiserror for libraries and anyhow for applications, including typed error enums, #[from] conversions, and recoverable vs panic decisions.
Ships in fuse-rust. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
It also covers the recoverable-errors-vs-panics decision — Result for anything a caller could reasonably recover from, panic!/unwrap/expect reserved for broken invariants — and the rule that anyhow::Error must never leak into a library's public API.
Out of scope: general ownership/borrowing design belongs to rust-core-language; async-runtime-specific error handling is not covered here.
The consensus split: thiserror for libraries, anyhow for applications. A library
exposes a typed error its callers can match; an application wants one ergonomic error
type and rich context. Getting this boundary right is the whole discipline.
thiserror / anyhow API
before writing derives (verification chain: fuse-browser fast-path on
docs.rs/thiserror and docs.rs/anyhow → Context7 → Exa).cargo clippy.| Crate kind | Tool | Why |
|---|---|---|
| Library (others depend on it) | thiserror | Typed enum, #[derive(Error)], callers can match on variants |
| Application (binary, top level) | anyhow | anyhow::Result<T>, ? everywhere, .context() for breadcrumbs |
| Simple / dep-free | hand-written std::error::Error | No dependency when one or two variants suffice |
anyhow::Error in a library's public API. It erases the type, so
callers cannot match or handle specific failures. Return a typed enum error.
thiserror is designed to not appear in your public API — switching to/from a
hand-written impl is not a breaking change.anyhow; libraries use thiserror. Do not pull anyhow into
a reusable library's signatures..context("...") /
.with_context(|| ...) turns "No such file or directory" into a traceable chain.#[from] for zero-boilerplate conversion, so ? lifts a source error into your
enum. #[from] implies #[source] — never write both.Result for anything a caller could
reasonably recover from. Reserve panic!/unwrap/expect for broken invariants.| Topic | Reference | Load when |
|---|---|---|
| thiserror (libraries) | thiserror-libraries.md | Building a typed error enum for a library API |
| anyhow (applications) | anyhow-applications.md | Handling errors in a binary / top-level app |
| Error design | error-design.md | Shaping enums, #[from] conversion, recoverable vs panic, the anyhow/thiserror boundary |
| Template | Load when |
|---|---|
| library-error.md | Need a complete thiserror library error module |
| application-error.md | Need a complete anyhow application entry point with context |
enum deriving thiserror::Error — no anyhow in the public APIanyhow::Result<T> and adds .context(...)#[from] used for source conversions; no redundant #[source] alongside it? used instead of unwrap() on fallible valuescargo clippy clean, sniper passedWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
7 skills in this plugin
/rust-async-concurrencyUse when writing async Rust — spawning tasks, sharing state across tasks/threads, choosing channels vs mutexes, or hitting Send-bound errors with async traits. Not for HTTP service structure (rust-web-backend) or sync-only ownership (rust-core-language)./rust-core-languageUse when writing or reviewing idiomatic Rust — edition 2024 ownership/borrowing design, or fixing LLM pitfalls (clone tax, unwrap infestation, indexed loops). Not for error-type design (rust-error-handling) or SOLID layout (solid-rust)./rust-ecosystem-cratesUse when choosing crates for a Rust project — serialization, CLI, async runtime, web, database, HTTP client, error handling, observability. Not for API usage details of an already-chosen crate.npx claudepluginhub fusengine/claude-plugins --plugin fuse-rustOther plugins' skills for the same job