handle-errors-in-code

Guides writing structured Rust error types using thiserror enums with context and actionable messages.

Updated Feb 21, 2026
One-click install
npx skills add https://github.com/joySUSY/violet-plugin-place --skill handle-errors-in-code-joysusy
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: handle-errors-in-code
Source: https://github.com/joySUSY/violet-plugin-place/tree/main/plugins/error-handling/references/v3-expansion/handle-errors-in-code
Command: npx skills add https://github.com/joySUSY/violet-plugin-place --skill handle-errors-in-code-joysusy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Rust projects often accumulate vague, unactionable error messages like "invalid input" or opaque anyhow errors that frustrate users and complicate debugging. This Skill provides a consistent guide for writing clear, contextual, and actionable error types. ## Core Features & Use Cases - Structured Error Enums: Promotes explicit thiserror-derived error enums over anyhow for pattern matching and clarity. - Context & Actionability Standards: Enforces what/where/when/why context in every error plus actionable fix instructions via Display and help() methods. - Unwrap/Expect Policy: Defines when .unwrap(), .expect(), and ? propagation are acceptable across production code, tests, and doc examples. - Use Case: When adding a new error variant for an SSH key failure, the Skill guides you to include the path, the cause, and the exact ssh-keygen command the user should run to fix it. ## Quick Start Ask the assistant to review or write a Rust error type following the project's error handling principles, for example: "Add a thiserror error variant for a network timeout with full context and a fix suggestion."

Frequently Asked Questions about handle-errors-in-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write good error types in Rust with thiserror?▼

Derive thiserror::Error on an enum where each variant carries structured fields like names, paths, or endpoints. Write Display messages that include what failed, where, and how to fix it, rather than generic strings.

Should I use anyhow or thiserror for Rust error handling?▼

This guide prefers explicit thiserror enums over anyhow because they are matchable and self-documenting. anyhow produces opaque errors that are hard to pattern match, so it is discouraged for structured error types.

When is it acceptable to use unwrap() in Rust?▼

unwrap() is acceptable in tests and doc examples but never in production code. In production, propagate errors with ? or use expect() only when failure is logically impossible, such as splitting a literal known to contain the delimiter.

How do I make Rust error messages actionable for users?▼

Include the failing resource and a concrete fix command in the Display output, such as the ssh-keygen command for a missing key. You can also add a help() method returning fix instructions per variant.

What context should a Rust error message include?▼

Each error should answer what operation was running, where it happened, under what conditions, and why it failed. For example, a network timeout error should include the operation name, endpoint, and timeout duration.