//! The gateway's error type.

use thiserror::Error;

/// Errors produced by the gateway state machine.
#[derive(Debug, Error, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
    /// A wire-format primitive failed to parse or encode.
    #[error("wire error: {0}")]
    Core(plexus_core::Error),
    /// A cryptographic operation failed.
    #[error("crypto error: {0}")]
    Crypto(plexus_crypto::Error),
    /// An Ed25519 signature did not verify.
    #[error("signature verification failed")]
    BadSignature,
    /// An announce's recomputed destination hash did not match the claimed one.
    #[error("announce address mismatch")]
    AddressMismatch,
    /// A buffer was too short to contain the expected structure.
    #[error("truncated")]
    Truncated,
    /// A referenced destination is not known.
    #[error("unknown destination")]
    UnknownDestination,
    /// A referenced link does not exist or is not active.
    #[error("unknown or inactive link")]
    UnknownLink,
}
