From e72d7bdf8bc31b7b0ad53d25f3742ba4808cdb4c Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Fri, 13 Jan 2023 00:39:58 +0200 Subject: [PATCH] Revert error details for the BadGame error --- CHANGELOG.md | 1 + src/errors.rs | 16 ++++++++-------- src/protocols/valve/protocol.rs | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 063322f..65f2106 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Valve Protocol: Players with no name are no more added to the `players_details` ### Breaking: Valve Protocol: The rules field is now a `HashMap` instead of a `Vec` (where the `ServerRule` structure had a name and a value fields). +Errors: Besides the `BadGame` error, now no other errors returns details about what happened (as it was quite pointless). # 0.0.7 - 03/01/2023 ### Changes: diff --git a/src/errors.rs b/src/errors.rs index 45e1aa3..ca360cf 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -19,22 +19,22 @@ pub enum GDError { PacketReceive, /// Couldn't decompress data. Decompress, - /// Unknown cast while translating a value to an enum. - UnknownEnumCast, - /// Invalid input. - InvalidInput, /// Couldn't create a socket connection. SocketConnect, /// Couldn't bind a socket. SocketBind, - /// Couldn't parse a json string. - JsonParse, - /// The server queried is not from the queried game. - BadGame, + /// Invalid input. + InvalidInput, + /// The server queried is not the queried game server. + BadGame(String), /// Couldn't automatically query. AutoQuery, /// A protocol-defined expected format was not met. ProtocolFormat, + /// Couldn't cast a value to an enum. + UnknownEnumCast, + /// Couldn't parse a json string. + JsonParse, /// Couldn't parse a value. TypeParse, } diff --git a/src/protocols/valve/protocol.rs b/src/protocols/valve/protocol.rs index fa489fe..3d5ba45 100644 --- a/src/protocols/valve/protocol.rs +++ b/src/protocols/valve/protocol.rs @@ -430,10 +430,10 @@ fn get_response(address: &str, port: u16, app: App, gather_settings: GatheringSe let info = client.get_server_info(&app)?; let protocol = info.protocol; - if let App::Source(x) = &app { - if let Some(appid) = x { + if let App::Source(source_app) = &app { + if let Some(appid) = source_app { if *appid != info.appid { - return Err(BadGame); + return Err(BadGame(format!("AppId: {appid}"))); } } }