aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-world
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-06-22 15:41:21 +0300
committerValentin Popov <valentin@popov.link>2026-06-22 15:41:21 +0300
commit8b91a0bfbf0097d145359c8508a61696ade812d1 (patch)
tree3e0f3c1c72034b13b73260fca204c101fc7aa379 /crates/fparkan-world
parentfb97405e0c47dadf656e5c92c76ddaff95d78222 (diff)
downloadfparkan-8b91a0bfbf0097d145359c8508a61696ade812d1.tar.xz
fparkan-8b91a0bfbf0097d145359c8508a61696ade812d1.zip
fix: make core error displays actionable
Diffstat (limited to 'crates/fparkan-world')
-rw-r--r--crates/fparkan-world/src/lib.rs22
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(