Skip to main content

codex_convert_proxy/
error.rs

1//! Error types for the library.
2
3use thiserror::Error;
4
5/// Error types for conversion operations.
6#[derive(Error, Debug)]
7pub enum ConversionError {
8    #[error("Missing required field: {0}")]
9    MissingField(String),
10
11    #[error("Invalid input format: {0}")]
12    InvalidFormat(String),
13
14    #[error("Provider error: {0}")]
15    ProviderError(String),
16
17    #[error("JSON error: {0}")]
18    JsonError(#[from] serde_json::Error),
19
20    /// tool_search_output's call_id does not match any registered tool_search_call.
21    #[error(
22        "tool_search call_id mismatch: expected '{expected}', got '{actual}'. \
23        The tool_search_output may be missing its corresponding tool_search_call."
24    )]
25    ToolSearchCallIdMismatch {
26        expected: String,
27        actual: String,
28    },
29}
30
31/// Error types for proxy operations.
32#[derive(Error, Debug)]
33pub enum ProxyError {
34    #[error("Connection error: {0}")]
35    ConnectionError(String),
36
37    #[error("Upstream error: {0}")]
38    UpstreamError(String),
39
40    #[error("Request error: {0}")]
41    RequestError(String),
42
43    #[error("Response error: {0}")]
44    ResponseError(String),
45
46    #[error("Conversion error: {0}")]
47    ConversionError(#[from] ConversionError),
48}