From b2ffaac1059c78cab63a9b8be485e000eaa04699 Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 23 Dec 2024 01:46:19 +0000 Subject: [PATCH] impl Debug for NonRootError --- simdnbt/src/error.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/simdnbt/src/error.rs b/simdnbt/src/error.rs index 3c6d35e..d09d94d 100644 --- a/simdnbt/src/error.rs +++ b/simdnbt/src/error.rs @@ -1,3 +1,5 @@ +use std::fmt::Debug; + use thiserror::Error; use crate::common::MAX_DEPTH; @@ -38,6 +40,7 @@ impl From for Error { } } } + impl NonRootError { #[inline] pub fn unexpected_eof() -> Self { @@ -62,6 +65,16 @@ impl From for NonRootError { NonRootError::unexpected_eof() } } +impl Debug for NonRootError { + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self.value { + 0 => write!(f, "UnexpectedEofError"), + 1 => write!(f, "MaxDepthExceededError"), + _ => write!(f, "UnknownTagId({})", self.value.wrapping_add(1)), + } + } +} #[derive(Error, Debug)] pub enum DeserializeError {