rust-error-handling

Define and propagate typed domain errors across Rust, Leptos, Axum, and SQLx apps.

Updated May 26, 2026
One-click install
npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill rust-error-handling-adelabdelgawad
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-error-handling
Source: https://github.com/adelabdelgawad/rust-fullstack-agents/tree/main/plugins/rusty/skills/rust-error-handling
Command: npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill rust-error-handling-adelabdelgawad

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Define, map, and propagate errors in Rust+Leptos+Axum+SQLx projects using thiserror, anyhow, IntoResponse, and FromServerFnError. Trigger keywords: error, AppError, thiserror, anyhow, Result, unwrap, propagate, 500, 404, 422, map_err, Box<dyn Error>, ServerFnError, IntoResponse. Auto-triggers on ANY new domain module, server fn, or Axum handler that can fail; on any compile error about missing From impls or ? operator incompatibility; on any handler returning a raw String error or leaking internal details to the HTTP response.

Core Features & Use Cases

  • Centralized AppError enum with #[from] variants to simplify error propagation.
  • Typed HTTP error mapping via IntoResponse to avoid leaking internal details.
  • ServerFn integration with FromServerFnError for client-server boundary safety.
  • Auto-triggers on compile-time errors related to From impls or ? operator compatibility and unsafe error leakage.

Quick Start

Add an AppError enum with From variants, wire IntoResponse, and propagate errors with ?, across domain and handler code.

Frequently Asked Questions about rust-error-handling

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

FAQPage Schema
How do I handle Rust errors in a Leptos and Axum web application?

Rust error handling in Leptos and Axum apps is managed by defining a centralized AppError enum using thiserror, implementing IntoResponse to map errors to HTTP status codes, and using FromServerFnError to safely cross the client-server boundary.

How do I fix missing From impls or ? operator compatibility compile errors in Rust?

Missing From impls and ? operator compatibility errors are resolved by adding #[from] attributes to your thiserror enum variants, enabling automatic conversion between underlying error types like sqlx::Error and your custom domain AppError.

What's the best way to prevent leaking internal error details in Axum HTTP responses?

Preventing internal error leakage in Axum HTTP responses requires implementing the IntoResponse trait for your AppError enum to map domain errors to generic, safe HTTP status codes like 500, 404, or 422 without exposing internal stack traces.

How do I propagate typed errors across Rust server functions?

Propagating typed errors across Rust server functions involves implementing the FromServerFnError trait for your AppError enum, ensuring that domain errors are safely mapped and transmitted across the server function boundary to the Leptos client.

When should I use thiserror vs anyhow for Rust error handling?

Use thiserror for library and domain code to define specific, typed AppError variants with compile-time checks, and use anyhow for application-level code where you need simple error aggregation without designing a dedicated error enum.

How do I map Rust application errors to HTTP status codes like 404 and 422?

Mapping Rust application errors to HTTP status codes like 404 and 422 is done by implementing the IntoResponse trait for your AppError enum, defining a match block that converts each typed error variant into the appropriate Axum HTTP response.