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-core/src/position.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-core/src/position.rs')
| -rw-r--r-- | azalea-core/src/position.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index adc5cafa..7371d530 100644 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -1,5 +1,5 @@ use crate::ResourceLocation; -use azalea_buf::{McBufReadable, McBufWritable}; +use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; use std::{ io::{Read, Write}, ops::Rem, @@ -225,7 +225,7 @@ impl From<&EntityPos> for ChunkPos { } impl McBufReadable for BlockPos { - fn read_from(buf: &mut impl Read) -> Result<Self, String> { + fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> { let val = u64::read_from(buf)?; let x = (val >> 38) as i32; let y = (val & 0xFFF) as i32; @@ -235,7 +235,7 @@ impl McBufReadable for BlockPos { } impl McBufReadable for GlobalPos { - fn read_from(buf: &mut impl Read) -> Result<Self, String> { + fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> { Ok(GlobalPos { dimension: ResourceLocation::read_from(buf)?, pos: BlockPos::read_from(buf)?, @@ -244,7 +244,7 @@ impl McBufReadable for GlobalPos { } impl McBufReadable for ChunkSectionPos { - fn read_from(buf: &mut impl Read) -> Result<Self, String> { + fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> { let long = i64::read_from(buf)?; Ok(ChunkSectionPos { x: (long >> 42) as i32, |
