kojacoord_protocol/
error.rs1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum ProtocolError {
5 #[error("unexpected end of packet data")]
6 UnexpectedEof,
7
8 #[error("variable-length integer overflow (read {0} bytes)")]
9 VarIntOverflow(usize),
10
11 #[error("string length {0} exceeds maximum {1}")]
12 StringTooLong(usize, usize),
13
14 #[error("string contains invalid UTF-8: {0}")]
15 InvalidUtf8(#[from] std::string::FromUtf8Error),
16
17 #[error("unknown packet id 0x{id:02X} in state {state:?} direction {direction:?}")]
18 UnknownPacketId {
19 id: u32,
20
21 state: String,
22
23 direction: String,
24 },
25
26 #[error("unrecognized NBT tag type: {0}")]
27 UnknownNbtTag(u8),
28
29 #[error("I/O error: {0}")]
30 Io(#[from] std::io::Error),
31
32 #[error("packet size {0} exceeds maximum {1}")]
33 PacketTooLarge(usize, usize),
34}