Skip to main content

web_search/
error.rs

1//! Error types for web search operations
2
3use thiserror::Error;
4
5/// Errors that can occur during web search operations
6#[derive(Error, Debug)]
7pub enum SearchError {
8    /// HTTP request failed
9    #[error("HTTP request failed: {0}")]
10    RequestError(#[from] reqwest::Error),
11
12    /// Failed to parse HTML response
13    #[error("Failed to parse HTML: {0}")]
14    ParseError(String),
15
16    /// Invalid URL
17    #[error("Invalid URL: {0}")]
18    UrlError(#[from] url::ParseError),
19
20    /// Provider not found
21    #[error("Unknown provider: {0}")]
22    UnknownProvider(String),
23
24    /// Provider is disabled
25    #[error("Provider {0} is disabled")]
26    ProviderDisabled(String),
27
28    /// API error from search provider
29    #[error("API error from {provider}: {message}")]
30    ApiError { provider: String, message: String },
31
32    /// Invalid configuration
33    #[error("Invalid configuration: {0}")]
34    ConfigError(String),
35
36    /// JSON serialization/deserialization error
37    #[error("JSON error: {0}")]
38    JsonError(#[from] serde_json::Error),
39}
40
41/// Result type alias for search operations
42pub type SearchResult<T> = std::result::Result<T, SearchError>;