rdap 0.2.0

A modern RDAP (Registration Data Access Protocol) client
Documentation
//! Error types for the RDAP client
//!
//! Defines [`RdapError`], the central error enum for all failure modes in
//! this crate, and a convenience [`Result`] type alias.

use thiserror::Error;

/// Convenience type alias for `std::result::Result<T, RdapError>`.
pub type Result<T> = std::result::Result<T, RdapError>;

/// Errors that can occur during RDAP operations.
///
/// Covers network failures, serialization issues, bootstrap discovery
/// problems, and RDAP-protocol-level errors returned by servers.
#[derive(Error, Debug)]
pub enum RdapError {
    /// An HTTP request to an RDAP server failed at the transport level.
    #[error("HTTP request failed: {0}")]
    Http(#[from] reqwest::Error),

    /// The server returned JSON that could not be deserialized into an RDAP model.
    #[error("JSON parsing failed: {0}")]
    Json(#[from] serde_json::Error),

    /// A filesystem I/O error occurred (e.g. reading/writing the bootstrap cache).
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    /// IANA bootstrap service discovery failed (no registry match, fetch error, etc.).
    #[error("Bootstrap error: {0}")]
    Bootstrap(String),

    /// The query string is malformed or cannot be interpreted as a valid RDAP query.
    #[error("Invalid query: {0}")]
    InvalidQuery(String),

    /// The RDAP server returned HTTP 404 — the queried object does not exist.
    #[error("Object not found (404)")]
    NotFound,

    /// All candidate RDAP servers were tried and none returned a successful response.
    #[error("No working RDAP servers found")]
    NoWorkingServers,

    /// The RDAP server returned an error response (non-404 HTTP error with body).
    #[error("RDAP server error {code}: {title}")]
    ServerError {
        /// HTTP status code returned by the server.
        code: u16,
        /// Human-readable error title from the RDAP error response.
        title: String,
        /// Detailed error description lines from the RDAP error response.
        description: Vec<String>,
    },

    /// A URL string could not be parsed into a valid URL.
    #[error("Invalid URL: {0}")]
    InvalidUrl(#[from] url::ParseError),

    /// The HTTP request timed out before a response was received.
    #[error("Timeout")]
    Timeout,

    /// A cache read/write operation failed.
    #[error("Cache error: {0}")]
    Cache(String),

    /// A catch-all error for situations not covered by the other variants.
    #[error("{0}")]
    Other(String),
}