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    /// Caller-owned transport failed.
13    #[error("Transport failed: {0}")]
14    Transport(String),
15
16    /// Failed to parse HTML response
17    #[error("Failed to parse HTML: {0}")]
18    ParseError(String),
19
20    /// Invalid URL
21    #[error("Invalid URL: {0}")]
22    UrlError(#[from] url::ParseError),
23
24    /// Provider not found
25    #[error("Unknown provider: {0}")]
26    UnknownProvider(String),
27
28    /// Provider is disabled
29    #[error("Provider {0} is disabled")]
30    ProviderDisabled(String),
31
32    /// API error from search provider
33    #[error("API error from {provider}: {message}")]
34    ApiError { provider: String, message: String },
35
36    /// Invalid configuration
37    #[error("Invalid configuration: {0}")]
38    ConfigError(String),
39
40    /// JSON serialization/deserialization error
41    #[error("JSON error: {0}")]
42    JsonError(#[from] serde_json::Error),
43}
44
45/// Result type alias for search operations
46pub type SearchResult<T> = std::result::Result<T, SearchError>;