From 8b91a0bfbf0097d145359c8508a61696ade812d1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 22 Jun 2026 16:41:21 +0400 Subject: fix: make core error displays actionable --- crates/fparkan-world/src/lib.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'crates/fparkan-world/src/lib.rs') diff --git a/crates/fparkan-world/src/lib.rs b/crates/fparkan-world/src/lib.rs index a253586..ec988ff 100644 --- a/crates/fparkan-world/src/lib.rs +++ b/crates/fparkan-world/src/lib.rs @@ -169,7 +169,15 @@ pub enum WorldError { impl std::fmt::Display for WorldError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{self:?}") + match self { + Self::InvalidHandle => write!(f, "object handle does not reference a known slot"), + Self::StaleHandle => write!(f, "object handle belongs to an older slot generation"), + Self::Deleted => write!(f, "object has already been deleted"), + Self::DuplicateOriginalObjectId(id) => { + write!(f, "original object id {} is already registered", id.0) + } + Self::InvalidFixedStep => write!(f, "fixed-step configuration must be non-zero"), + } } } @@ -632,6 +640,18 @@ mod tests { ); } + #[test] + fn world_error_display_is_actionable() { + assert_eq!( + WorldError::StaleHandle.to_string(), + "object handle belongs to an older slot generation" + ); + assert_eq!( + WorldError::DuplicateOriginalObjectId(OriginalObjectId(8)).to_string(), + "original object id 8 is already registered" + ); + } + #[test] fn identity_metadata_keeps_original_mirror_and_owner_distinct() { let mut world = new(WorldConfig); -- cgit v1.2.3