diff options
Diffstat (limited to 'crates/fparkan-world')
| -rw-r--r-- | crates/fparkan-world/src/lib.rs | 22 |
1 files changed, 21 insertions, 1 deletions
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"), + } } } @@ -633,6 +641,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); let handle = construct_object( |
