Skip to main content

Module error

Module error 

Source
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 Error enum for all error conditions
  • Structured Context: Rich ErrorContext for debugging information
  • Actionable Hints: User-friendly suggestions for error resolution
  • Error Classification: Retryable and fallbackable error marking

§Error Categories

VariantDescription
ProtocolProtocol specification errors
PipelineStreaming pipeline errors
ConfigurationConfiguration and setup errors
ValidationInput validation errors
RuntimeRuntime execution errors
TransportNetwork transport errors
RemoteRemote 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§

ErrorContext
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