mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
Remove errors details as they were quite useless
This commit is contained in:
parent
e8619a7df1
commit
c263b17651
13 changed files with 103 additions and 116 deletions
|
|
@ -1,9 +1,6 @@
|
|||
|
||||
//! The library's possible errors.
|
||||
|
||||
use core::fmt;
|
||||
use std::fmt::Formatter;
|
||||
|
||||
/// Result of Type and GDError.
|
||||
pub type GDResult<T> = Result<T, GDError>;
|
||||
|
||||
|
|
@ -11,55 +8,33 @@ pub type GDResult<T> = Result<T, GDError>;
|
|||
#[derive(Debug, Clone)]
|
||||
pub enum GDError {
|
||||
/// The received packet was bigger than the buffer size.
|
||||
PacketOverflow(String),
|
||||
PacketOverflow,
|
||||
/// The received packet was shorter than the expected one.
|
||||
PacketUnderflow(String),
|
||||
/// The received packet was badly formatted.
|
||||
PacketBad(String),
|
||||
PacketUnderflow,
|
||||
/// The received packet is badly formatted.
|
||||
PacketBad,
|
||||
/// Couldn't send the packet.
|
||||
PacketSend(String),
|
||||
PacketSend,
|
||||
/// Couldn't send the receive.
|
||||
PacketReceive(String),
|
||||
PacketReceive,
|
||||
/// Couldn't decompress data.
|
||||
Decompress(String),
|
||||
Decompress,
|
||||
/// Unknown cast while translating a value to an enum.
|
||||
UnknownEnumCast,
|
||||
/// The server queried is not from the queried game.
|
||||
BadGame(String),
|
||||
/// Couldn't bind a socket.
|
||||
SocketBind(String),
|
||||
/// Invalid input.
|
||||
InvalidInput(String),
|
||||
InvalidInput,
|
||||
/// Couldn't create a socket connection.
|
||||
SocketConnect(String),
|
||||
SocketConnect,
|
||||
/// Couldn't bind a socket.
|
||||
SocketBind,
|
||||
/// Couldn't parse a json string.
|
||||
JsonParse(String),
|
||||
JsonParse,
|
||||
/// The server queried is not from the queried game.
|
||||
BadGame,
|
||||
/// Couldn't automatically query.
|
||||
AutoQuery,
|
||||
/// A protocol-defined expected format was not met.
|
||||
ProtocolFormat(String),
|
||||
ProtocolFormat,
|
||||
/// Couldn't parse a value.
|
||||
TypeParse(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for GDError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
GDError::PacketOverflow(details) => write!(f, "Packet overflow: {details}"),
|
||||
GDError::PacketUnderflow(details) => write!(f, "Packet underflow: {details}"),
|
||||
GDError::PacketBad(details) => write!(f, "Packet bad: {details}"),
|
||||
GDError::PacketSend(details) => write!(f, "Couldn't send a packet: {details}"),
|
||||
GDError::PacketReceive(details) => write!(f, "Couldn't receive a packet: {details}"),
|
||||
GDError::Decompress(details) => write!(f, "Couldn't decompress data: {details}"),
|
||||
GDError::UnknownEnumCast => write!(f, "Unknown enum cast encountered."),
|
||||
GDError::BadGame(details) => write!(f, "Queried another game that the supposed one: {details}"),
|
||||
GDError::SocketBind(details) => write!(f, "Socket bind: {details}"),
|
||||
GDError::InvalidInput(details) => write!(f, "Invalid input: {details}"),
|
||||
GDError::SocketConnect(details) => write!(f, "Socket connect: {details}"),
|
||||
GDError::JsonParse(details) => write!(f, "Json parse: {details}"),
|
||||
GDError::AutoQuery => write!(f, "Auto query failed."),
|
||||
GDError::ProtocolFormat(details) => write!(f, "Protocol rule: {details}"),
|
||||
GDError::TypeParse(details) => write!(f, "Type parse: {details}"),
|
||||
}
|
||||
}
|
||||
TypeParse,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue