From: Tayrtahn Date: Fri, 28 Mar 2025 15:37:34 +0000 (-0400) Subject: Make ContainerFillSystem print contents on failure (#36128) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=99484ad7442e8a2b2641437e155986ac2b5e6cb3;p=space-station-14.git 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 --- 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; }