Skip to content
Back to skills

Rust Error

ASecurity

Define, wrap, convert, classify, report or test Rust error types in litellm-rust with thiserror. Use when adding an error type or variant, mapping one crate's error into another, turning an error into a gateway response or Python exception, deciding retry or fault from an error, or replacing call sites that build errors from strings

  • 64,529 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added November 10, 2026
ai-agentspythonrusttesting

Works with

  • cli

Security analysis

A100/100

Pro scans all 10 files and shows the line behind each finding

Scanned November 10, 2026

npx -y skills add BerriAI/litellm --skill rust-error --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rust Error?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rust Error
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/berriai-rust-error/badge)](https://www.skillsdirectory.com/skills/berriai-rust-error)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: rust-error
description: Define, wrap, convert, classify, report or test Rust error types in litellm-rust with thiserror. Use when adding an error type or variant, mapping one crate's error into another, turning an error into a gateway response or Python exception, deciding retry or fault from an error, or replacing call sites that build errors from strings
metadata:
  internal: true
---

# Rust errors

`crates/http/src/error.rs` is the reference implementation. Read the reference for the part you are touching before editing, each one carries the reasoning and worked examples behind its rules

- [shape](references/shape.md)
  - One top-level `Error` per crate in `src/error.rs`. A public enum by default, an opaque struct over a private `Repr` enum when the variants must stay private. No `#[non_exhaustive]`
  - A variant is a failure mode a caller handles differently. Provider names and guidance are data, never variants
- [messages and causes](references/messages-and-causes.md)
  - Every message is written once, in `#[error(...)]`, and describes its own layer only. Call sites pass typed facts, never a string
  - The cause is the `source()`, never part of the message. Keep it typed, never stringify or drop it
  - `reqwest::Error` enters our types only through `litellm_http::Error`, which strips its URL
  - Anything shown to someone else is rendered with `litellm_error::Report`, never `to_string()`
- [conversions](references/conversions.md)
  - One `From` per source and target pair, only when the conversion needs no context. It classifies and sanitizes once
  - Nest a lower crate's error in one variant. Translate when the meaning changes, never mirror its variants
- [classification](references/classification.md)
  - Callers ask predicates named after their decision, they do not match nested variants. Predicates match exhaustively
  - Classification states facts. Retry and fallback policy lives with the caller that knows idempotency
- [boundaries](references/boundaries.md)
  - An error becomes text for someone else only in one mapping function per error type, in the gateway crates, the Python bridge and host-python. The inference gateway and the bridge decide by the same predicates
  - A failure before the provider was called is a decline. Both ask `declined()` first and hand it back to the host unchanged
- [gateway](references/gateway.md)
  - One `Error` with `IntoResponse` per gateway crate that serves a router. Every failure flows through the same `From` chain, is classified once in `status()` and rendered by surface and framing
- [pyo3](references/pyo3.md)
  - Two `create_exception!` classes with the payload in `args`, `ValueError` for the caller's fault and `RuntimeError` otherwise, decoded in `failures.py`
- [testing](references/testing.md)
  - Test predicates, chain shape and redaction on errors built the way production builds them
- [recipes](references/recipes.md)
  - Common tasks walked through end to end

The workspace uses thiserror 2 for every error type, and no library crate uses `anyhow` or `Box<dyn Error>` in a public signature. The [derive docs](https://docs.rs/thiserror/latest/thiserror/) are the authority on macro behavior, and the [`std::error::Error` docs](https://doc.rust-lang.org/std/error/trait.Error.html) on what `Display` and `source()` mean

Files in this skill

  • SKILL.md3.3 KB
  • references/boundaries.md4.5 KB
  • references/classification.md4.5 KB
  • references/conversions.md3.8 KB
  • references/gateway.md4.8 KB
  • references/messages-and-causes.md6.8 KB
  • references/pyo3.md7.5 KB
  • references/recipes.md4.2 KB
  • references/shape.md5.9 KB
  • references/testing.md2.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.