netcode/
error.rs

1use thiserror::Error;
2
3/// The result type for all the public methods that can return an error in this crate.
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// An error that can occur in the `netcode` crate.
7#[derive(Error, Debug)]
8#[non_exhaustive]
9pub enum Error {
10    #[error("buffer size mismatch, expected {0} but got {1}")]
11    SizeMismatch(usize, usize),
12    #[error("tried to send a packet to a client that doesn't exist")]
13    ClientNotFound,
14    #[error("tried to send a packet to a client that isn't connected")]
15    ClientNotConnected,
16    #[error("clock went backwards (did you invent a time machine?): {0}")]
17    SystemTime(#[from] std::time::SystemTimeError),
18    #[error("invalid connect token: {0}")]
19    InvalidToken(crate::token::InvalidTokenError),
20    #[error(transparent)]
21    Socket(#[from] crate::socket::Error),
22    #[error(transparent)]
23    Crypto(#[from] crate::crypto::Error),
24    #[error("invalid packet: {0}")]
25    Packet(#[from] crate::packet::Error),
26    #[error(transparent)]
27    Io(#[from] std::io::Error),
28}