From 99484ad7442e8a2b2641437e155986ac2b5e6cb3 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Fri, 28 Mar 2025 11:37:34 -0400 Subject: [PATCH] Make ContainerFillSystem print contents on failure (#36128) * Make ContainerFill/EntityTableContainerFill print current contents when failing to spawn an entity * List each entry on a new line; add fallback for empty --- Content.Shared/Containers/ContainerFillSystem.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Containers/ContainerFillSystem.cs b/Content.Shared/Containers/ContainerFillSystem.cs index 90eccb0341..3d49079ea7 100644 --- a/Content.Shared/Containers/ContainerFillSystem.cs +++ b/Content.Shared/Containers/ContainerFillSystem.cs @@ -1,3 +1,4 @@ +using System.Linq; using System.Numerics; using Content.Shared.EntityTable; using Robust.Shared.Containers; @@ -39,7 +40,8 @@ public sealed class ContainerFillSystem : EntitySystem var ent = Spawn(proto, coords); if (!_containerSystem.Insert(ent, container, containerXform: xform)) { - Log.Error($"Entity {ToPrettyString(uid)} with a {nameof(ContainerFillComponent)} failed to insert an entity: {ToPrettyString(ent)}."); + var alreadyContained = container.ContainedEntities.Count > 0 ? string.Join("\n", container.ContainedEntities.Select(e => $"\t - {EntityManager.ToPrettyString(e)}")) : "< empty >"; + Log.Error($"Entity {ToPrettyString(uid)} with a {nameof(ContainerFillComponent)} failed to insert an entity: {ToPrettyString(ent)}.\nCurrent contents:\n{alreadyContained}"); _transform.AttachToGridOrMap(ent); break; } @@ -72,7 +74,8 @@ public sealed class ContainerFillSystem : EntitySystem var spawn = Spawn(proto, coords); if (!_containerSystem.Insert(spawn, container, containerXform: xform)) { - Log.Error($"Entity {ToPrettyString(ent)} with a {nameof(EntityTableContainerFillComponent)} failed to insert an entity: {ToPrettyString(spawn)}."); + var alreadyContained = container.ContainedEntities.Count > 0 ? string.Join("\n", container.ContainedEntities.Select(e => $"\t - {EntityManager.ToPrettyString(e)}")) : "< empty >"; + Log.Error($"Entity {ToPrettyString(ent)} with a {nameof(EntityTableContainerFillComponent)} failed to insert an entity: {ToPrettyString(spawn)}.\nCurrent contents:\n{alreadyContained}"); _transform.AttachToGridOrMap(spawn); break; } -- 2.51.2