salvo-error-handling

Installation
SKILL.md

Salvo Error Handling

StatusError

Return a StatusError from any handler that is Result<T, StatusError>:

use salvo::prelude::*;

#[handler]
async fn get_user(req: &mut Request) -> Result<Json<User>, StatusError> {
    let id = req.param::<i64>("id")
        .ok_or_else(|| StatusError::bad_request().brief("Missing user ID"))?;

    find_user(id).await
        .ok_or_else(|| StatusError::not_found().brief("User not found"))
        .map(Json)
}
Installs
25
GitHub Stars
20
First Seen
Feb 10, 2026
salvo-error-handling — salvo-rs/salvo-skills