ghast_world/error.rs
1use thiserror::Error;
2
3use crate::ChunkPos;
4
5/// Malformed world data from the server. 1.8 leaves the column the way vanilla does (see
6/// `v1_8::World::apply_chunk_data`); 1.12 and 1.16 unload it.
7#[derive(Debug, Clone, PartialEq, Eq, Error)]
8#[non_exhaustive]
9pub enum WorldError {
10 /// Chunk data is shorter than its section mask requires.
11 #[error("chunk {pos:?}: data too short ({len} bytes, need {need})")]
12 Truncated {
13 /// Column.
14 pos: ChunkPos,
15 /// Bytes received.
16 len: usize,
17 /// Bytes required.
18 need: usize,
19 },
20 /// A 1.8 map_chunk_bulk whose data does not cover all listed columns.
21 #[error("map_chunk_bulk: data too short ({len} bytes, need {need})")]
22 BulkTruncated {
23 /// Bytes received.
24 len: usize,
25 /// Bytes required.
26 need: usize,
27 },
28 /// A 1.16 section is malformed.
29 #[error("chunk {pos:?} section {section}: {reason}")]
30 Section {
31 /// Column.
32 pos: ChunkPos,
33 /// Section index (`y >> 4`).
34 section: u8,
35 /// What is wrong.
36 reason: &'static str,
37 },
38 /// A world packet could not be decoded (26.1 raw packet handling).
39 #[error("world packet: {0}")]
40 Decode(ghast_protocol::DecodeError),
41}