Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Rust Errors?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/dankosik-rust-errors-cargo-modernize)
---
name: rust-errors
description: "Failure semantics. Use when defining Rust errors, failure mappings, exit codes, degradation, or fallible completion."
---
# Rust Errors
**Failure semantics.** Trace failure from the operation that observes it to the consumer that acts on it, separating rejected inputs, partial effects, uncertain outcomes, and post-commit cleanup failures so each boundary can stop, degrade, retry, or continue accurately.
**Consumer-driven types.** Expose typed variants where callers branch on recovery, while letting report-and-exit boundaries use contextual errors. Implement `std::error::Error`, `Display`, and `Debug` (via `thiserror`) on public library error types, preserving upstream `#[source]` causes and adding variants only for real consumers.
**Context and redaction.** Attach safe resource identifiers or input positions at the failing operation, verify what the boundary renderer actually emits from the `source()` chain, keep messages lowercase and free of trailing punctuation, redact secrets across every nested cause, and preserve failure precedence and all-or-nothing guarantees.
**Conversions and retries.** Implement `From` for context-free canonical conversions and use `map_err` where operation context disambiguates the failure; match structured variants rather than formatted strings. Require safe effect and idempotency identity before retrying timeouts or broken connections, log ignored cleanup failures only under an explicit best-effort policy, and represent help or early clean exits as normal `Ok` outcomes.
**Fallible completion and panics.** Expose an explicit observed close or flush method whenever resource completion can fail or await, reserving `Drop` for infallible non-blocking release and keeping primary outcomes distinct from cleanup errors. Use `catch_unwind` solely as task-boundary defense in depth, observe spawned-task failures via their supervisor, and re-establish or quarantine any multi-step invariant a panic could leave partial before exposing shared state.
**Project boundaries.** Keep per-file parser or detector failures (including panics caught by the scan worker's `catch_unwind`) contained to that file and accounted in the run summary rather than aborting the workspace scan; keep `--fix` transactional so a failed `cargo check` rolls edits back; and map outcomes to process exit status only in `crates/cargo-modernize/src/main.rs`, where `--check` findings and real errors stay distinguishable. Test these mappings behaviorally rather than boilerplate variants.