leptos-error-handling

Map Leptos domain errors to HTTP responses and client messages.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Leptos apps that mix server functions, Axum endpoints, and view components often leak internal errors or present inconsistent user-facing messages. This Skill provides a structured approach to defining AppError, mapping sqlx errors, and wiring IntoResponse and ErrorBoundary to deliver safe, consistent error handling across server and client boundaries.

Core Features & Use Cases

  • AppError pattern: Domain error enum must be Clone + Serialize + Deserialize; implement FromServerFnError for server fn error framing.
  • SQLx error mapping: Map RowNotFound to NotFound; map database errors to Internal with logs for debugging.
  • IntoResponse integration: Implement IntoResponse for AppError to produce appropriate HTTP status codes and error bodies.
  • ErrorBoundary usage: Wrap UI closures with ErrorBoundary to catch Domain errors during rendering.
  • Validation pattern: Use AppError::Validation for input validation errors to return 422s with helpful messages.

Quick Start

Define AppError, implement FromServerFnError, map SQLx errors, and wire IntoResponse and ErrorBoundary in your Leptos/Axum app.

Frequently Asked Questions about leptos-error-handling

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

FAQPage Schema
How do I handle server function errors in Leptos without leaking internal details?

To handle Leptos server function errors safely, define an AppError enum implementing FromServerFnError to frame errors and prevent leaking internal details to the client. This approach maps domain errors into serializable, client-friendly messages.

How do I map SQLx database errors to HTTP responses in an Axum application?

Map SQLx database errors to HTTP responses in Axum by implementing the IntoResponse trait for your AppError enum. This translates sqlx::Error variants, such as RowNotFound to NotFound status codes, and logs database errors internally before returning safe HTTP responses.

How do I display validation errors to users in a Leptos view component?

Display validation errors to users in Leptos by returning an AppError::Validation variant from your server function. This returns a 422 HTTP status with helpful messages, which you can catch and render by wrapping your UI closures with the ErrorBoundary view component.

Does AppError need to be serializable to work with Leptos server functions?

Yes, AppError must be Clone, Serialize, and Deserialize to work effectively with Leptos server functions. Serialization is required to transmit the error state cleanly across the WebAssembly client and server boundary for consistent rendering.

What is the best way to structure a unified error handling layer for Leptos and Axum?

The best way to structure a unified error handling layer for Leptos and Axum is creating a single AppError domain enum. This centralizes error logic by implementing FromServerFnError for server functions and IntoResponse for Axum endpoints, ensuring consistent HTTP status codes and safe error bodies across both environments.