salvo-error-handling

Handle Salvo web API errors with custom types and JSON payloads.

20|5|Updated Jan 11, 2026
One-click install
npx skills add https://github.com/salvo-rs/salvo-skills --skill salvo-error-handling
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: salvo-error-handling
Source: https://github.com/salvo-rs/salvo-skills/tree/main/skills/salvo-error-handling
Command: npx skills add https://github.com/salvo-rs/salvo-skills --skill salvo-error-handling

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a structured approach to error handling in Salvo-based web APIs, ensuring consistent error responses, clear diagnostics, and safer control flow across handlers.

Core Features & Use Cases

  • Custom error types with Writer implementations to render standardized JSON error payloads.
  • StatusError-based maps to HTTP status codes for business and system errors.
  • Panic handling integration using CatchPanic to convert panics into controlled responses and logs.

Quick Start

Implement a custom error type, map it with StatusError in handlers, and apply CatchPanic for global safety.

Frequently Asked Questions about salvo-error-handling

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

FAQPage Schema
How do I handle errors in a Rust Salvo web API?

To handle errors in a Rust Salvo web API, you can implement custom error types with Writer implementations to render standardized JSON error payloads and map them using StatusError to appropriate HTTP status codes.

How does CatchPanic work for centralized error handling in Rust APIs?

CatchPanic works by intercepting panics in your Rust API handlers, converting them into controlled responses and logs to ensure safe, centralized failure management and prevent server crashes.

How do I return consistent JSON error responses from a Salvo middleware?

You can return consistent JSON error responses from Salvo middleware by building custom error types that implement the Writer trait, ensuring structured and standardized payloads across all handlers.

Does Salvo support mapping custom business errors to HTTP status codes?

Yes, Salvo supports mapping custom business errors to HTTP status codes using StatusError-based maps, allowing you to translate system and business logic failures into accurate REST API responses.

What is the best way to structure error handling in a Salvo REST API?

The best way to structure error handling in a Salvo REST API is to combine custom error types for standardized JSON payloads with CatchPanic for global safety, ensuring clear diagnostics and safer control flow.

Why do unhandled panics crash my Salvo API and how can I prevent it?

Unhandled panics crash your Salvo API because they propagate without interception; you can prevent this by applying CatchPanic middleware to convert panics into controlled JSON responses and logs.