Source code for nadzoring.utils.errors

"""Centralized exception hierarchy for Nadzoring.

All public exceptions are defined here so that consumers can import
from a single location and catch errors at the appropriate granularity.

Exception messages should use the literal error strings defined in
module-specific errors.py files where applicable.
"""


[docs] class NadzoringError(Exception): """Base exception for all Nadzoring errors."""
# --------------------------------------------------------------------------- # DNS errors # ---------------------------------------------------------------------------
[docs] class DNSError(NadzoringError): """Base exception for DNS-related failures."""
[docs] class DNSResolutionError(DNSError): """Raised when a DNS query cannot be resolved."""
[docs] class DNSTimeoutError(DNSError): """Raised when a DNS query times out."""
[docs] class DNSDomainNotFoundError(DNSError): """Raised when the queried domain does not exist (NXDOMAIN)."""
[docs] class DNSNoRecordsError(DNSError): """Raised when a domain exists but has no records of the requested type."""
# --------------------------------------------------------------------------- # Network errors # ---------------------------------------------------------------------------
[docs] class NetworkError(NadzoringError): """Base exception for network-related failures."""
[docs] class HostResolutionError(NetworkError): """Raised when a hostname cannot be resolved to an IP address."""
[docs] class ConnectionTimeoutError(NetworkError): """Raised when a network connection attempt times out."""
[docs] class UnsupportedPlatformError(NetworkError): """Raised when the current OS is not supported by a function."""
# --------------------------------------------------------------------------- # ARP errors # ---------------------------------------------------------------------------
[docs] class ARPError(NadzoringError): """Base exception for ARP-related failures."""
[docs] class ARPCacheRetrievalError(ARPError): """Raised when reading the ARP cache fails. The exception message should be one of the strings defined in :mod:`nadzoring.arp.errors`. """
# --------------------------------------------------------------------------- # Input validation errors # ---------------------------------------------------------------------------
[docs] class ValidationError(NadzoringError): """Raised when user-supplied input fails validation."""
[docs] class InvalidIPAddressError(ValidationError): """Raised when a string is not a valid IP address."""
[docs] class InvalidDomainError(ValidationError): """Raised when a string is not a valid domain name."""
[docs] class InvalidPortError(ValidationError): """Raised when a port number is outside the valid 1-65535 range."""