From 527333f2b78a749cc1d1c0813e059726efe46d8d Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 21 Dec 2024 00:02:54 +0000 Subject: [PATCH] more verbose login_disconnect error --- .../src/packets/login/c_login_disconnect.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/azalea-protocol/src/packets/login/c_login_disconnect.rs b/azalea-protocol/src/packets/login/c_login_disconnect.rs index a0e50aa43..580bfb2c2 100755 --- a/azalea-protocol/src/packets/login/c_login_disconnect.rs +++ b/azalea-protocol/src/packets/login/c_login_disconnect.rs @@ -4,6 +4,7 @@ use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError}; use azalea_chat::FormattedText; use azalea_protocol_macros::ClientboundLoginPacket; use serde::{Deserialize, Serialize}; +use tracing::trace; #[derive(Clone, Debug, ClientboundLoginPacket)] pub struct ClientboundLoginDisconnect { @@ -13,7 +14,16 @@ pub struct ClientboundLoginDisconnect { impl AzaleaRead for ClientboundLoginDisconnect { fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result { let disconnect_string = String::azalea_read(buf)?; - let disconnect_json: serde_json::Value = serde_json::from_str(disconnect_string.as_str())?; + trace!("Got disconnect packet with string: {disconnect_string:?}"); + let disconnect_json = + match serde_json::from_str::(disconnect_string.as_str()) { + Ok(json) => json, + Err(err) => { + return Err(BufReadError::Custom(format!( + "Failed to deserialize disconnect JSON {disconnect_string:?}: {err}" + ))) + } + }; Ok(ClientboundLoginDisconnect { reason: FormattedText::deserialize(disconnect_json)?,