1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Error types module
//!
//! This module contains error types used throughout the P2P Foundation.
/// Main error type for P2P Foundation
#[derive(Debug, thiserror::Error)]
pub enum P2PError {
/// Network-related error (connections, peers, protocols)
#[error("Network error: {0}")]
Network(String),
/// DHT operation error (lookups, storage, routing)
#[error("DHT error: {0}")]
DHT(String),
/// Transport layer error (QUIC, TCP, tunneling)
#[error("Transport error: {0}")]
Transport(String),
/// Security-related error (authentication, encryption, validation)
#[error("Security error: {0}")]
Security(String),
/// MCP server error (tool calls, message routing)
#[error("MCP error: {0}")]
MCP(String),
/// Bootstrap cache error (peer discovery, cache management)
#[error("Bootstrap error: {0}")]
Bootstrap(String),
/// Configuration error (invalid settings, missing parameters)
#[error("Configuration error: {0}")]
Config(String),
/// IO error (file operations, network IO)
#[error("IO error: {0}")]
IO(#[from] std::io::Error),
/// Serialization error (JSON, protocol encoding/decoding)
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
/// Generic error (catch-all for other error types)
#[error("Generic error: {0}")]
Generic(#[from] anyhow::Error),
}
/// Result type alias for P2P Foundation operations
pub type Result<T> = std::result::Result<T, P2PError>;