1use thiserror::Error;
4
5use crate::types::NbtString;
6
7#[derive(Debug, Error, Clone, PartialEq, Eq, PartialOrd, Ord)]
9pub enum ParseError {
10 #[error("Invalid tag ID: {0}")]
12 InvalidTagId(u8),
13 #[error("Unexpected end of input")]
15 UnexpectedEndOfInput,
16 #[error("Invalid UTF-8 data")]
18 InvalidUtf8,
19 #[error("Negative length encountered: {0}")]
21 NegativeLength(i32),
22 #[error("Leftover data: {0} bytes")]
24 LeftoverData(usize),
25 #[error("Duplicate tag name")]
27 DuplicateTagName(NbtString),
28 #[error("Not an NBT file")]
30 NotNBT,
31}
32
33#[derive(Debug, Error, Clone, PartialEq, Eq, PartialOrd, Ord)]
35pub enum ValidationError {
36 #[error("The array is to long {0}/{max}", max = i32::MAX)]
38 ArrayTooLong(usize),
39 #[error("The string is to long {0}/{max}", max = u16::MAX)]
41 StringTooLong(usize),
42}