Expand description
Error types for Astrea
/ Astrea 的错误类型定义
Provides a structured error type that integrates with Axum’s response system
while being compatible with third-party error types via anyhow.
提供结构化的错误类型,与 Axum 响应系统集成,同时通过 anyhow 兼容第三方错误类型。
§Example
§示例
ⓘ
use astrea::prelude::*;
#[route]
pub async fn handler(event: Event) -> Result<Response> {
let user_id = get_param_required(&event, "id")?;
if user_id.is_empty() {
return Err(RouteError::bad_request("User ID cannot be empty"));
}
json(json!({ "user_id": user_id }))
}Enums§
- Route
Error - Main error type for route handlers
Type Aliases§
- Result
- Type alias for Result with RouteError / Result 类型的别名,使用 RouteError 作为错误类型