Skip to main content

Module error

Module error 

Source
Expand description

§Error Types

Error types for the Bob Agent Framework.

This module provides comprehensive error handling with:

  • AgentError: Top-level error enum wrapping all error types
  • LlmError: Errors from LLM providers
  • ToolError: Errors from tool execution
  • StoreError: Errors from session storage

§Error Codes

Every error variant carries a stable machine-readable error code (e.g. "BOB_LLM_RATE_LIMITED", "BOB_TOOL_TIMEOUT"). Codes are stable across patch releases and can be used for monitoring, alerting rules, and structured error reporting.

§Error Handling Strategy

All errors use thiserror for ergonomic error definitions and implement:

  • std::error::Error for compatibility
  • Display for user-friendly messages
  • From for automatic conversion

§Example

use bob_core::error::{AgentError, LlmError};

fn handle_error(err: AgentError) {
    eprintln!("[{}] {}", err.code(), err);
    match err {
        AgentError::Llm(e) => eprintln!("LLM error: {}", e),
        AgentError::Tool(e) => eprintln!("Tool error: {}", e),
        AgentError::Policy(msg) => eprintln!("Policy violation: {}", msg),
        AgentError::Timeout => eprintln!("Operation timed out"),
        _ => eprintln!("Other error: {}", err),
    }
}

Enums§

AgentError
Top-level agent error.
CostError
Cost meter errors.
LlmError
LLM adapter errors.
StoreError
Session store errors.
ToolError
Tool execution errors.