1use crate::ProtocolVersion;
7use std::borrow::Cow;
8use thiserror::Error;
9
10#[derive(Debug, Error, Clone, PartialEq)]
15pub enum ProtocolError {
16 #[error("Consensus error: {0}")]
18 Consensus(#[from] blvm_consensus::error::ConsensusError),
19
20 #[error("Protocol validation failed: {0}")]
22 Validation(Cow<'static, str>),
23
24 #[error("Feature not supported: {0}")]
26 UnsupportedFeature(String),
27
28 #[error("Protocol version mismatch: expected {expected:?}, got {actual:?}")]
30 VersionMismatch {
31 expected: ProtocolVersion,
32 actual: ProtocolVersion,
33 },
34
35 #[error("Network parameter error: {0}")]
37 NetworkParameter(Cow<'static, str>),
38
39 #[error("Configuration error: {0}")]
41 Configuration(Cow<'static, str>),
42
43 #[error("Message size exceeds protocol limit: {size} bytes (max {max} bytes)")]
45 MessageTooLarge { size: usize, max: usize },
46
47 #[error("Invalid protocol message: {0}")]
49 InvalidMessage(Cow<'static, str>),
50
51 #[error("Service flag error: {0}")]
53 ServiceFlag(Cow<'static, str>),
54
55 #[error("Serialization error: {0}")]
57 Serialization(String),
58}
59
60pub type Result<T> = std::result::Result<T, ProtocolError>;