diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-08-06 07:22:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-06 02:22:19 -0500 |
| commit | 5a9fca0ca9cdb46f4b866781f219756c89e2293a (patch) | |
| tree | b006e28b91a181734fb9702bb6ec510f5b2af3df /azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs | |
| parent | 1d48c3fe34edd4e2295f54bd3d79f81f58c38a8e (diff) | |
| download | azalea-drasl-5a9fca0ca9cdb46f4b866781f219756c89e2293a.tar.xz | |
Better errors (#14)
* make reading use thiserror
* finish implementing all the error things
* clippy warnings related to ok_or
* fix some errors in other places
* thiserror in more places
* don't use closures in a couple places
* errors in writing packet
* rip backtraces
* change some BufReadError::Custom to UnexpectedEnumVariant
* Errors say what packet is bad
* error on leftover data and fix
it wasn't reading the properties for gameprofile
Diffstat (limited to 'azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs')
| -rw-r--r-- | azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs index a2caae4b..7414e10c 100644 --- a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs @@ -1,4 +1,4 @@ -use azalea_buf::{BitSet, McBuf, McBufReadable, McBufVarWritable}; +use azalea_buf::{BitSet, BufReadError, McBuf, McBufReadable, McBufVarWritable}; use azalea_buf::{McBufVarReadable, McBufWritable}; use azalea_chat::component::Component; use azalea_crypto::{MessageSignature, SignedMessageHeader}; @@ -74,13 +74,15 @@ pub enum FilterMask { } impl McBufReadable for FilterMask { - fn read_from(buf: &mut impl Read) -> Result<Self, String> { + fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> { let filter_mask = u32::var_read_from(buf)?; match filter_mask { 0 => Ok(FilterMask::PassThrough), 1 => Ok(FilterMask::FullyFiltered), 2 => Ok(FilterMask::PartiallyFiltered(BitSet::read_from(buf)?)), - _ => Err("Invalid filter mask".to_string()), + _ => Err(BufReadError::UnexpectedEnumVariant { + id: filter_mask as i32, + }), } } } |
