flarer 0.1.0

Rust client and CLI for Cloudflare's Browser Rendering REST API (content, screenshot, PDF, snapshot, markdown, scrape, JSON extraction, links, crawl).
Documentation
//! Strongly-typed errors for the `flarer` crate.

use thiserror::Error;

/// Crate-wide `Result` alias.
pub type Result<T> = std::result::Result<T, FlarerError>;

/// All errors that can be produced by the `flarer` library.
#[derive(Debug, Error)]
pub enum FlarerError {
    /// Transport-level HTTP error from `reqwest`.
    #[error("HTTP transport error: {0}")]
    Http(#[from] reqwest::Error),

    /// Cloudflare API returned a non-2xx response.
    #[error("Cloudflare API error (HTTP {status}): {body}")]
    Api {
        /// HTTP status code.
        status: u16,
        /// Raw response body, often JSON describing the failure.
        body: String,
    },

    /// Authentication / token verification failed.
    #[error("authentication failed: {0}")]
    Auth(String),

    /// A required configuration value (token, account id, ...) is missing.
    #[error("configuration error: {0}")]
    Config(String),

    /// JSON (de)serialization failure.
    #[error(transparent)]
    Serde(#[from] serde_json::Error),

    /// Filesystem I/O failure.
    #[error(transparent)]
    Io(#[from] std::io::Error),

    /// Base64 decode failure (e.g. snapshot screenshot payload).
    #[error("base64 decode error: {0}")]
    Base64(#[from] base64::DecodeError),

    /// URL parse failure.
    #[error("invalid URL: {0}")]
    Url(#[from] url::ParseError),

    /// The Cloudflare response shape was not what we expected.
    #[error("unexpected response: {0}")]
    Unexpected(String),
}