Expand description
Error type for the library 错误处理模块:提供统一的错误类型和结构化错误上下文。
§Error Handling Module
This module provides unified error types and structured error contexts for comprehensive error handling across the ai-lib-rust library.
§Overview
The error system provides:
- Unified Error Type: Single
Errorenum for all error conditions - Structured Context: Rich
ErrorContextfor debugging information - Actionable Hints: User-friendly suggestions for error resolution
- Error Classification: Retryable and fallbackable error marking
§Error Categories
| Variant | Description |
|---|---|
Protocol | Protocol specification errors |
Pipeline | Streaming pipeline errors |
Configuration | Configuration and setup errors |
Validation | Input validation errors |
Runtime | Runtime execution errors |
Transport | Network transport errors |
Remote | Remote API errors (with HTTP status) |
§Example
use ai_lib_rust::error::{Error, ErrorContext};
// Create error with context
let error = Error::validation_with_context(
"Invalid temperature value",
ErrorContext::new()
.with_field_path("request.temperature")
.with_details("Value must be between 0.0 and 2.0")
.with_hint("Try setting temperature to 0.7 for balanced output"),
);Re-exports§
pub use crate::pipeline::PipelineError as Pipeline;pub use crate::protocol::ProtocolError as Protocol;
Structs§
- Error
Context - Structured error context for better error handling and debugging.
Enums§
- Error
- Unified error type for the AI-Protocol Runtime This aggregates all low-level errors into actionable, high-level categories