Skip to main content

elizaos_plugin_copilot_proxy/
error.rs

1//! Error types for the Copilot Proxy plugin.
2
3use thiserror::Error;
4
5/// Errors that can occur when using the Copilot Proxy client.
6#[derive(Error, Debug)]
7pub enum CopilotProxyError {
8    /// HTTP request failed.
9    #[error("HTTP request failed: {0}")]
10    HttpError(#[from] reqwest::Error),
11
12    /// JSON serialization/deserialization error.
13    #[error("JSON error: {0}")]
14    JsonError(#[from] serde_json::Error),
15
16    /// API returned an error response.
17    #[error("Copilot Proxy API error ({status}): {message}")]
18    ApiError {
19        /// HTTP status code.
20        status: u16,
21        /// Error message from the API.
22        message: String,
23    },
24
25    /// Invalid configuration.
26    #[error("Invalid configuration: {0}")]
27    ConfigError(String),
28
29    /// API returned an empty response.
30    #[error("API returned empty response")]
31    EmptyResponse,
32
33    /// URL parsing error.
34    #[error("URL parsing error: {0}")]
35    UrlError(#[from] url::ParseError),
36
37    /// Failed to extract JSON from response.
38    #[error("Failed to extract JSON: {0}")]
39    JsonExtractionError(String),
40
41    /// Request timed out.
42    #[error("Request timed out after {0} seconds")]
43    Timeout(u64),
44
45    /// Plugin is disabled.
46    #[error("Plugin is disabled")]
47    Disabled,
48}
49
50/// Result type alias for Copilot Proxy operations.
51pub type Result<T> = std::result::Result<T, CopilotProxyError>;