Skip to main content

ave_network/
error.rs

1//! # Network errors.
2
3use serde::{Deserialize, Serialize};
4use thiserror::Error;
5
6/// Errors produced by the network layer.
7#[derive(Debug, Error, Serialize, Deserialize, Clone)]
8pub enum Error {
9    /// Failed to extract or decode the local Ed25519 secret key.
10    #[error("failed to extract Ed25519 secret key: {0}")]
11    KeyExtraction(String),
12
13    /// Failed to initialise the Noise authentication layer.
14    #[error("failed to build Noise transport: {0}")]
15    NoiseBuild(String),
16
17    /// Failed to initialise the DNS transport.
18    #[error("failed to build DNS transport: {0}")]
19    DnsBuild(String),
20
21    /// A multiaddress string could not be parsed or is invalid.
22    #[error("invalid multiaddress: {0}")]
23    InvalidAddress(String),
24
25    /// The swarm could not start listening on the requested address.
26    #[error("failed to listen on address: {0}")]
27    Listen(String),
28
29    /// Failed to send a response on a request-response channel.
30    #[error("failed to send response on request-response channel")]
31    ResponseSend,
32
33    /// Message payload exceeds accepted maximum size.
34    #[error("network message too large: {size} bytes (max {max})")]
35    MessageTooLarge {
36        /// Actual message size in bytes.
37        size: usize,
38        /// Configured maximum accepted message size in bytes.
39        max: usize,
40    },
41
42    /// No reachable bootstrap node; the network is unavailable.
43    #[error("cannot connect to the ave network: no reachable bootstrap node")]
44    NoBootstrapNode,
45
46    /// The network task was cancelled via its cancellation token.
47    #[error("network task cancelled")]
48    Cancelled,
49
50    /// Failed to forward a command to the network worker.
51    #[error("failed to send command to network worker: {0}")]
52    CommandSend(String),
53}