# Convert Rust Errors Idiomatically

Rust error conversions can become repetitive and confusing across application layers. This skill guides Claude, Codex, and Claude Code toward idiomatic From, map_err, anyhow, and thiserror patterns.

## Install

```bash
npx skillstore add emillindfors/error-conversion-guide
```

## Metadata

- Status: approved
- Slug: emillindfors-error-conversion-guide
- Version: 1.0.0
- Author version: 1.0.0
- Skillstore revision: r1
- Version status: valid
- Tree hash: 079cacd983ca74e5a6e69443da942802f51ae484aa9f331268f6240dbf5fac7f
- Author: EmilLindfors
- GitHub username: EmilLindfors
- License: MIT
- Repository: https://github.com/EmilLindfors/claude-marketplace/tree/main/plugins/rust-error-handling/skills/error-conversion-guide
- Ref: a06681402992ceae98ba04d54cfd4ab004862696
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, network
- Quality score: 79
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/emillindfors-error-conversion-guide
- Manifest: https://skillstore.pages.dev/api/skills/emillindfors-error-conversion-guide/manifest

## Capabilities

- Recommends automatic error conversion with From and thiserror source variants.
- Explains when to use manual From implementations for custom conversion logic.
- Shows when map\_err, anyhow context, boxed errors, and Result aliases are appropriate.
- Guides layered error conversion between infrastructure, domain, and application boundaries.
- Identifies common Rust error conversion mistakes that lose context or cause conflicts.

## Use Cases

- Replace Repetitive Conversions: Convert repeated map\_err calls into cleaner automatic conversions when source errors map directly to application errors.
- Design Public Error Types: Choose between thiserror, anyhow, boxed errors, and type aliases for library and application boundaries.
- Review Layered Services: Map infrastructure, domain, and service errors without leaking low-level details across boundaries.

## Prompt Templates

### Convert Manual Errors

```
Review this Rust function and suggest a clearer error conversion pattern. Explain whether From, map_err, or anyhow fits best.
```

### Fix Question Mark Errors

```
I get a Rust error when using the ? operator with two error types. Explain the missing conversion and suggest the smallest fix.
```

### Design Error Enum

```
Design an idiomatic Rust error enum for these operations and dependencies. Include guidance on automatic and manual conversions.
```

### Refactor Layered Errors

```
Analyze these infrastructure, domain, and application errors. Propose a layered conversion strategy that preserves context and clear ownership.
```

## Limitations

- It does not compile, run, or test Rust code.
- It focuses on Rust error conversion, not broad architecture review.
- It depends on code snippets and compiler messages supplied by the user.
- Project-specific error policies may require manual adaptation.

## Best Practices

- Use automatic conversion when one source error clearly maps to one variant.
- Preserve original error sources when callers need diagnostics or chaining.
- Convert errors at architecture boundaries where terminology changes.

## Anti Patterns

- Do not convert every error to a string before returning it.
- Do not add multiple automatic conversions from the same source type.
- Do not expose infrastructure errors directly from domain interfaces.

## Security Audit

- Audited at: 2026-07-06T14:46:57.439\+00:00
- Summary: All 44 static findings are false positives caused by Markdown backticks, Rust code examples, a sample fetch method name, and an error message. No evidence was found for prompt injection, executable scripts, network exfiltration, or system reconnaissance in SKILL.md.

## Stats

- Views: 156
- Downloads: 9
- Favorites: 0
- Popularity score: 0
