webpage_info/
error.rs

1//! Error types for webpage-info
2
3use thiserror::Error;
4
5/// Errors that can occur when fetching or parsing webpage information.
6#[derive(Debug, Error)]
7pub enum Error {
8    /// Failed to parse or validate the URL
9    #[error("invalid URL: {0}")]
10    InvalidUrl(String),
11
12    /// URL parse error (from url crate)
13    #[error("URL parse error: {0}")]
14    UrlParse(#[from] url::ParseError),
15
16    /// HTTP request failed
17    #[cfg(feature = "http")]
18    #[error("HTTP request failed: {0}")]
19    Http(#[from] reqwest::Error),
20
21    /// Failed to read file
22    #[error("failed to read file: {0}")]
23    Io(#[from] std::io::Error),
24
25    /// HTML parsing error
26    #[error("failed to parse HTML")]
27    ParseError,
28
29    /// Invalid response (non-HTML content type)
30    #[error("invalid content type: expected HTML, got {0}")]
31    InvalidContentType(String),
32
33    /// Request blocked due to SSRF protection
34    #[cfg(feature = "http")]
35    #[error("SSRF protection: {0}")]
36    SsrfBlocked(String),
37}
38
39/// Result type alias for webpage-info operations.
40pub type Result<T> = std::result::Result<T, Error>;